home *** CD-ROM | disk | FTP | other *** search
/ Computer Music 2004 January / Computer Music Magazine 68 2004.iso / pc / Software / PC Software / Demo Software / Actinic Audio Store / Audio.exe / CatalogInstaller.EXE / ACTINIC.pm < prev   
Encoding:
Perl POD Document  |  2000-07-29  |  236.7 KB  |  7,090 lines

  1. #!perl
  2. #**************************************************************************
  3. #
  4. # ACTINIC.pm    - module for common functions among the Actinic scripts
  5. #
  6. # Written by George Menyhert
  7. #
  8. # Copyright (c) Actinic Software Ltd 1998
  9. #
  10. #**************************************************************************
  11.  
  12. package ACTINIC;
  13. require 5.002;
  14.  
  15. use Socket;
  16. use strict;
  17.  
  18. #
  19. # define some global constants
  20. #
  21. $::FALSE     = 0;                                            # return codes
  22. $::TRUE         = 1;
  23.  
  24. $::FAILURE     = 0;
  25. $::SUCCESS     = 1;
  26. $::NOTFOUND = 2;
  27. $::FAILEDSEARCH = $::NOTFOUND;                        # synonyms
  28. $::EOF        = 3;
  29. $::EOB         = 4;
  30. $::BADDATA    = 5;
  31. $::WARNING    = 6;
  32. $::ACCEPTED    = 7;
  33. $::REJECTED    = 8;
  34. $::PENDING    = 9;
  35.  
  36. $::VARPREFIX     = 'NETQUOTEVAR:';                        # template variables
  37. $::DELPREFIX     = 'NETQUOTEDEL:';                        # template delimiters
  38.  
  39. $::RBBYTE     = 0;                                        # enumeration of the field types
  40. $::RBWORD     = 1;
  41. $::RBDWORD    = 2;
  42. $::RBQWORD    = 3;
  43. $::RBSTRING   = 4;
  44. $::RBKEY      = 5;
  45.  
  46. $::HIDDEN    = 0;                                            # the prompt status
  47. $::OPTIONAL    = 1;
  48. $::REQUIRED = 2;
  49.  
  50. $::PAYMENT_CREDIT_CARD                = 0;                # the various payment methods
  51. $::PAYMENT_CASH_ON_DELIVERY        = 1;
  52. $::PAYMENT_CHECK_ON_DELIVERY        = 2;
  53. $::PAYMENT_INVOICE                    = 3;
  54. $::PAYMENT_INVOICE_PRE_PAY            = 4;
  55. $::PAYMENT_CREDIT_CARD_SEPARATE    = 5;
  56.  
  57. $::ORDER_AID_NONE            = 0;                            # the order aid methods
  58. $::ORDER_AID_COMPLETE    = 1;
  59. $::ORDER_AID_RESPOND        = 2;
  60. $::ORDER_AID_CONTINUE    = 3;
  61.  
  62. $::LOCK_SH = 1;                                            # flock - share permissions
  63. $::LOCK_EX = 2;                                            # flock - exclusive lock
  64. $::LOCK_NB = 4;                                            # flock - non-blocking (can be or'ed with others)
  65. $::LOCK_UN = 8;                                            # flock - unlock
  66.  
  67. $::g_sRequiredColor    = '#aa3333';                    # the "required" field color
  68.  
  69. $::g_sCancelButtonLabel = '';                            # the global button labels
  70. $::g_sConfirmButtonLabel = '';
  71. $::g_sAddToButtonLabel = '';
  72. $::g_sEditButtonLabel = '';
  73. $::g_sRemoveButtonLabel = '';
  74. $::g_sSearchButtonLabel = '';
  75.  
  76. $::s_nErrorRecursionCounter = 0;
  77.  
  78. umask (0177);                                                # update the process umask
  79.     
  80. #
  81. # define some ACTINIC package constants
  82. #
  83.  
  84. $ACTINIC::prog_name = 'ACTINIC.pm';                    # Program Name 
  85. $ACTINIC::prog_name = $ACTINIC::prog_name;        # remove compiler warning
  86. $ACTINIC::prog_ver = '$Revision: 216 $ ';                # program version
  87. $ACTINIC::prog_ver = substr($ACTINIC::prog_ver, 11); # strip the revision information
  88. $ACTINIC::prog_ver =~ s/ \$//;                        # and the trailers
  89.  
  90. $ACTINIC::BILLCONTACT     = "INVOICE";
  91. $ACTINIC::SHIPCONTACT     = "DELIVERY";
  92. $ACTINIC::SHIPINFO         = "SHIPPING";
  93. $ACTINIC::TAXINFO         = "TAX";
  94. $ACTINIC::GENERALINFO     = "GENERAL";
  95. $ACTINIC::PAYMENTINFO     = "PAYMENT";
  96. $ACTINIC::LOCATIONINFO     = "LOCATION";
  97.  
  98. $ACTINIC::FILE                = 0;
  99. $ACTINIC::SDTOUT            = 1;
  100. $ACTINIC::MEMORY            = 2;
  101.  
  102. $ACTINIC::s_bTraceSocket = $::FALSE;
  103. $ACTINIC::s_bTraceSockFirstPass = $::TRUE;
  104. $ACTINIC::s_bTraceFileFirstPass = $::TRUE;
  105.  
  106. $ACTINIC::ORDER_BLOB_MAGIC = hex('10');
  107. $ACTINIC::ORDER_DETAIL_BLOB_MAGIC = hex("11");
  108.  
  109. $ACTINIC::FORM_URL_ENCODED             = 0;            # standard application/x-www-form-urlencoded (%xx) encoding
  110. $ACTINIC::MODIFIED_FORM_URL_ENCODED    = 1;            # Actinic format - identical to eParameter except an
  111.                                                                 # underscore is used instead of a percent sign and the string is
  112.                                                                 # prepended with an "a"
  113.  
  114. $ACTINIC::B2B = new ACTINIC_B2B();                    # Create B2B object to keep B2B parameters
  115. $ACTINIC::USESAFE = $::TRUE;                            # If true we attempt to use Safe.pm
  116. $ACTINIC::USESAFEONLY = $::FALSE;                    # If true, eval is only allowed in Safe.pm
  117.  
  118. $ACTINIC::MAX_RETRY_COUNT      = 10;
  119. $ACTINIC::RETRY_SLEEP_DURATION = 1;
  120. $ACTINIC::DOS_SLEEP_DURATION = 2;
  121.  
  122. $ACTINIC::AssertIsActive = $::FALSE;                # true if an assert is being reported
  123. $ACTINIC::AssertIsLooping = $::FALSE;                # true if the assert function appears to be stuck in a loop
  124.  
  125. #######################################################
  126. #
  127. # GetActinicDate - Get the current date in Actinic
  128. #    format (GMT server time)
  129. #
  130. # Returns:     the date in YYYY/MM/DD HH:MM format
  131. #
  132. #######################################################
  133.  
  134. sub GetActinicDate
  135.     {
  136.     #
  137.     # !!!!!! This is a function commonly used by many utilities.  Any changes to its interface will
  138.     # !!!!!! need to be verified with the various utility scripts.
  139.     #
  140.     
  141.     #
  142.     # Get the current date/time on the server
  143.     #
  144.     my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst, $sDate);
  145.     ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = gmtime(time);    # platform independent time
  146.     $mon++;                                                    # make month 1 based
  147.     $year += 1900;                                            # make year AD based
  148.     $sDate = sprintf("%4.4d/%2.2d/%2.2d %2.2d:%2.2d", $year, $mon, $mday, $hour, $min);
  149.     #
  150.     # Misc info
  151.     #
  152.     return($sDate);                                        # the date
  153.     }
  154.  
  155. #######################################################
  156. #
  157. # InitMonthMap - initialize the month maps.  This
  158. #    subroutine must be called after ReadPromptFile.
  159. #
  160. # Affects:     %::g_MonthMap (hash table mapping month names
  161. #                    to their numbers
  162. #                %::g_InverseMonthMap - hash table inversion
  163. #                    of %::g_MonthMap
  164. #
  165. #######################################################
  166.  
  167. sub InitMonthMap
  168.     {
  169.     %::g_MonthMap = (GetPhrase(-1, 0), 1,            # hash to convert month to digit
  170.                         GetPhrase(-1, 1), 2,
  171.                         GetPhrase(-1, 2), 3,
  172.                         GetPhrase(-1, 3), 4,
  173.                         GetPhrase(-1, 4), 5,
  174.                         GetPhrase(-1, 5), 6,
  175.                         GetPhrase(-1, 6), 7,
  176.                         GetPhrase(-1, 7), 8,
  177.                         GetPhrase(-1, 8), 9,
  178.                         GetPhrase(-1, 9), 10,
  179.                         GetPhrase(-1, 10), 11,
  180.                         GetPhrase(-1, 11), 12);
  181.     my ($key, $value);
  182.     while ( ($key, $value) = each %::g_MonthMap)    # build a revers map
  183.         {
  184.         $::g_InverseMonthMap{$value} = $key;
  185.         }
  186.     }
  187.  
  188. #######################################################
  189. #
  190. # GetCountryName - map the country code to country name
  191. #
  192. # Params:    0 - country code
  193. #
  194. # Returns:    0 - country name or undef on error
  195. #
  196. #######################################################
  197.  
  198. sub GetCountryName
  199.     {
  200. #? ACTINIC::ASSERT($#_ == 0, "Invalid argument count in CountryName ($#_)", __LINE__, __FILE__);
  201. #? ACTINIC::ASSERT(defined $::g_pLocationList, "Location list undefined", __LINE__, __FILE__);
  202.     my $sCode = $_[0];
  203.     return ($$::g_pLocationList{$sCode});
  204.     }
  205.  
  206. #######################################################
  207. #
  208. # GetHostname - attempt to retrieve the hostname
  209. #
  210. #    Returns:    0 - hostname or IP address or ''
  211. #
  212. #######################################################
  213.  
  214. sub GetHostname
  215.     {
  216.     my $sLocalhost = $ENV{SERVER_NAME};                # try the environment
  217.     $sLocalhost =~ s/[^-a-zA-Z0-9.]//g;                # strip any bad characters
  218.  
  219.     if (!$sLocalhost)                                        # if still no hostname is found
  220.         {
  221.         $sLocalhost = $ENV{HOST};                        # try a different environment variable
  222.         $sLocalhost =~ s/[^-a-zA-Z0-9.]//g;            # strip any bad characters
  223.         }
  224.     if (!$sLocalhost)                                        # if still no hostname is found
  225.         {
  226.         $sLocalhost = $ENV{HTTP_HOST};                # try a different environment variable
  227.         $sLocalhost =~ s/[^-a-zA-Z0-9.]//g;            # strip any bad characters
  228.         }
  229.     if (!$sLocalhost)                                        # if still no hostname is found
  230.         {
  231.         $sLocalhost = $ENV{LOCALDOMAIN};                # try a different environment variable
  232.         $sLocalhost =~ s/[^-a-zA-Z0-9.]//g;            # strip any bad characters
  233.         }
  234.     if (!$sLocalhost)                                        # if still no hostname is found
  235.         {
  236.         $sLocalhost = `hostname`;                        # try the command line
  237.         $sLocalhost =~ s/[^-a-zA-Z0-9.]//g;            # strip any bad characters
  238.         }
  239.     if (!$sLocalhost &&                                    # if still no hostname and 
  240.          $^O eq 'MSWin32')                                # NT
  241.         {
  242.         my $sHost = `ipconfig`;                            # run ipconfig and gather the collection of addresses
  243.         $sHost =~ /IP Address\D*([0-9.]*)/;            # get the first address in the list
  244.         $sLocalhost = $1;
  245.         $sLocalhost =~ s/[^-a-zA-Z0-9.]//g;            # strip any bad characters
  246.         }
  247.  
  248.     return ($sLocalhost);
  249.     }
  250.     
  251. #######################################################
  252. #
  253. # SendMail - Send an email to the specified email
  254. #    address if this service has been requested.
  255. #
  256. #    Params:    0 - the smtp server ip address
  257. #                1 - the destination email address
  258. #                2 - the subject
  259. #                3 - the message
  260. #           4 - optional return address
  261. #
  262. #    Returns:    0 - status
  263. #                1 - message
  264. #
  265. #######################################################
  266.  
  267. sub SendMail
  268.     {
  269. #? ACTINIC::ASSERT($#_ >= 3, "Invalid argument count in SendMail ($#_)", __LINE__, __FILE__);
  270.  
  271.     #
  272.     # !!!!!! This is a function commonly used by many utilities.  Any changes to its interface will
  273.     # !!!!!! need to be verified with the various utility scripts.
  274.     #
  275.     
  276.     if ($#_ < 3)
  277.         {
  278.         return($::FAILURE, GetPhrase(-1, 12, 'Actinic::SendMail'), 0, 0);
  279.         }
  280.     
  281.     my ($sSmtpServer, $sEmailAddress, $sSubjectText, $sMessageText, $sReturnAddress) = @_;
  282.     #
  283.     # pass it on to the rich mail function
  284.     #
  285.     return(SendRichMail($sSmtpServer, $sEmailAddress, $sSubjectText, $sMessageText, "", $sReturnAddress));
  286.     }
  287.  
  288. #######################################################
  289. #
  290. # SendRichMail - Send an email to the specified email
  291. #    address if this service has been requested.
  292. #
  293. #    Params:    0 - the smtp server ip address
  294. #                1 - the destination email address
  295. #                2 - the subject
  296. #                3 - the message as text
  297. #                4 - the message as HTML
  298. #           5 - optional return address
  299. #
  300. #    Returns:    0 - status
  301. #                1 - message
  302. #
  303. #######################################################
  304.  
  305. sub SendRichMail
  306.     {
  307. #? ACTINIC::ASSERT($#_ >= 4, "Invalid argument count in SendRichMail ($#_)", __LINE__, __FILE__);
  308.  
  309.     #
  310.     # !!!!!! This is a function commonly used by many utilities.  Any changes to its interface will
  311.     # !!!!!! need to be verified with the various utility scripts.
  312.     #
  313.     
  314.     if ($#_ < 4)
  315.         {
  316.         return($::FAILURE, GetPhrase(-1, 12, 'Actinic::SendRichMail'), 0, 0);
  317.         }
  318.     
  319.     my ($sSmtpServer, $sEmailAddress, $sLocalError, $sSubjectText, $sMessageText, $sMessageHTML, $sBoundary, $sReturnAddress);
  320.     ($sSmtpServer, $sEmailAddress, $sSubjectText, $sMessageText, $sMessageHTML, $sReturnAddress) = @_;
  321.     if (!$sReturnAddress)                                # if no return address defined
  322.         {
  323.         $sReturnAddress = $sEmailAddress;            # use the destination email address
  324.         }
  325.     #
  326.     # Gather the SMTP host, server, and socket information
  327.     #
  328.     my ($nProto, $them, $nSmtpPort, $sLocalHost, $sMessage, $serverIP);
  329.     
  330.     my $sLocalhost = GetHostname();                        # get the local machine ip address
  331.     if ($sLocalhost eq '')
  332.         {
  333.         $sLocalhost = 'www.actinic.com';
  334.         }
  335.     
  336.     $nProto = getprotobyname('tcp');
  337.     $nSmtpPort = 25;                                        # Use default port
  338.     
  339.     $serverIP = inet_aton($sSmtpServer);            # due the dns lookup and get the ip address    
  340.     if (!defined $serverIP)
  341.         {
  342.         return($::FAILURE, GetPhrase(-1, 13, $!), 0, 0); # Record internal error 
  343.         }
  344.     
  345.     $them = sockaddr_in($nSmtpPort, $serverIP);    # create the sockaddr
  346.     if (!defined $them)
  347.         {
  348.         return($::FAILURE, GetPhrase(-1, 14, $!), 0, 0); # Record internal error 
  349.         }
  350.     
  351.     unless (socket(MYSOCKET, PF_INET, SOCK_STREAM, $nProto))    # create the socked
  352.         {
  353.         return($::FAILURE, GetPhrase(-1, 15, $!), 0, 0); # Record internal error 
  354.         }
  355.     
  356.     unless (connect(MYSOCKET, $them))                # connect to the remote host
  357.         {
  358.         $sLocalError = GetPhrase(-1, 16, $!);        # Record internal error 
  359.         close MYSOCKET;
  360.         return($::FAILURE, $sLocalError, 0, 0);
  361.         }
  362.     
  363.     binmode MYSOCKET;                                        # just incase
  364.     
  365.     my($oldfh) = select(MYSOCKET);                    # make MYSOCKET the current file handle
  366.     $| = 1;                                                    # make each command send a flush
  367.     select($oldfh);                                        # return to the default file handle
  368.     
  369.     $sMessage = <MYSOCKET>;                                # see what the SMTP server has to say
  370.     if ($sMessage =~ /^[45]/)                            # check for failures from the SMTP server
  371.         {
  372.         $sLocalError = GetPhrase(-1, 17, 1, $sMessage);    # Record internal error 
  373.         close MYSOCKET;
  374.         return($::FAILURE, $sLocalError, 0, 0);
  375.         }
  376.     
  377.     unless (print MYSOCKET "HELO $sLocalhost\r\n")    # start the conversation with the SMTP server
  378.         {
  379.         $sLocalError = GetPhrase(-1, 18, 1, $!);    # Record internal error 
  380.         close MYSOCKET;
  381.         return($::FAILURE, $sLocalError, 0, 0);
  382.         }
  383.     
  384.     $sMessage = <MYSOCKET>;                                # see what the SMTP server has to say
  385.     if ($sMessage =~ /^[45]/)                            # check for failures
  386.         {
  387.         $sLocalError = GetPhrase(-1, 17, 2, $sMessage);    # Record internal error 
  388.         close MYSOCKET;
  389.         return($::FAILURE, $sLocalError, 0, 0);
  390.         }
  391.     
  392.     unless (print MYSOCKET "MAIL FROM:<" . $sReturnAddress . ">\r\n") # specify the origin
  393.         {
  394.         $sLocalError = GetPhrase(-1, 18, 2, $!);    # Record internal error 
  395.         close MYSOCKET;
  396.         return($::FAILURE, $sLocalError, 0, 0);
  397.         }
  398.     
  399.     $sMessage = <MYSOCKET>;                                # see what the SMTP server has to say
  400.     if ($sMessage =~ /^[45]/)                            # check for failures
  401.         {
  402.         $sLocalError = GetPhrase(-1, 17, 3, $sMessage);    # Record internal error 
  403.         close MYSOCKET;
  404.         return($::FAILURE, $sLocalError, 0, 0);
  405.         }
  406.     
  407.     unless (print MYSOCKET "RCPT TO:<",$sEmailAddress,">\r\n") # reciepient is always the supplier
  408.         {
  409.         $sLocalError = GetPhrase(-1, 18, 3, $!);    # Record internal error 
  410.         close MYSOCKET;
  411.         return($::FAILURE, $sLocalError, 0, 0);
  412.         }
  413.     
  414.     $sMessage = <MYSOCKET>;                                # see what the SMTP server has to say
  415.     if ($sMessage =~ /^[45]/)                            # check for failures
  416.         {
  417.         $sLocalError = GetPhrase(-1, 17, 4, $sMessage);    # Record internal error 
  418.         close MYSOCKET;
  419.         return($::FAILURE, $sLocalError, 0, 0);
  420.         }
  421.     
  422.     unless (print MYSOCKET "DATA\r\n")                # the rest of the is the message body until the <CRLF>.<CRLF>
  423.         {
  424.         $sLocalError = GetPhrase(-1, 18, 4, $!);    # Record internal error 
  425.         close MYSOCKET;
  426.         return($::FAILURE, $sLocalError, 0, 0);
  427.         }
  428.     
  429.     $sMessage = <MYSOCKET>;                                # see what the SMTP server has to say
  430.     if ($sMessage =~ /^[45]/)                            # check for failure
  431.         {
  432.         $sLocalError = GetPhrase(-1, 17, 5, $sMessage);    # Record internal error 
  433.         close MYSOCKET;
  434.         return($::FAILURE, $sLocalError, 0, 0);
  435.         }
  436.  
  437.     if ($sMessageText ne '' && $sMessageHTML ne '')# if both messages are specified
  438.         {
  439.         #
  440.         # make up our multi-part boundary from the order number
  441.         #
  442.         $sBoundary = "------------" . $::g_InputHash{ORDERNUMBER};
  443.         #
  444.         # let server know we are sending MIME
  445.         #
  446.         unless (print MYSOCKET "MIME-Version: 1.0\r\n") # MIME version
  447.             {
  448.             $sLocalError = GetPhrase(-1, 18, 11, $!);    # Record internal error 
  449.             close MYSOCKET;
  450.             return($::FAILURE, $sLocalError, 0, 0);
  451.             }
  452.         }
  453.     else                                                        # this isn't a multi-part message
  454.         {
  455.         $sBoundary = "";                                    # clear the boundary
  456.         }
  457.  
  458.     unless (print MYSOCKET "From: $sReturnAddress\r\n") # subject
  459.         {
  460.         $sLocalError = GetPhrase(-1, 18, 5, $!);    # Record internal error 
  461.         close MYSOCKET;
  462.         return($::FAILURE, $sLocalError, 0, 0);
  463.         }
  464.     
  465.     unless (print MYSOCKET "Subject: $sSubjectText\r\n") # subject
  466.         {
  467.         $sLocalError = GetPhrase(-1, 18, 6, $!);    # Record internal error 
  468.         close MYSOCKET;
  469.         return($::FAILURE, $sLocalError, 0, 0);
  470.         }
  471.     
  472.     unless (print MYSOCKET "To: $sEmailAddress\r\n") # subject
  473.         {
  474.         $sLocalError = GetPhrase(-1, 18, 7, $!);    # Record internal error 
  475.         close MYSOCKET;
  476.         return($::FAILURE, $sLocalError, 0, 0);
  477.         }
  478.     
  479.     unless (print MYSOCKET "Reply-To: $sReturnAddress\r\n") # subject
  480.         {
  481.         $sLocalError = GetPhrase(-1, 18, 8, $!);    # Record internal error 
  482.         close MYSOCKET;
  483.         return($::FAILURE, $sLocalError, 0, 0);
  484.         }
  485.     
  486.     if ($sBoundary ne '')                                # if both message types are specified
  487.         {
  488.         my $sContentMultipart = "Content-Type: multipart/alternative; ";
  489.         $sContentMultipart .= "boundary=\"" . $sBoundary . "\"\r\n\r\n";
  490.  
  491.         unless (print MYSOCKET $sContentMultipart) # content-type
  492.             {
  493.             $sLocalError = GetPhrase(-1, 18, 12, $!);    # Record internal error 
  494.             close MYSOCKET;
  495.             return($::FAILURE, $sLocalError, 0, 0);
  496.             }
  497.         }
  498.  
  499.     unless (print MYSOCKET "\r\n")                    # blank line
  500.         {
  501.         $sLocalError = GetPhrase(-1, 18, 8, $!);    # Record internal error 
  502.         close MYSOCKET;
  503.         return($::FAILURE, $sLocalError, 0, 0);
  504.         }
  505.     
  506.     if ($sBoundary ne '')                                # if both message types are specified
  507.         {
  508.         #
  509.         # send the text multipart 
  510.         #
  511.         my $sTextMultipart = "--" . $sBoundary . "\r\n";
  512.         $sTextMultipart .= "Content-Type: text/plain; charset=us-ascii\r\n";
  513.         $sTextMultipart .= "Content-Transfer-Encoding: 7bit\r\n\r\n" . $sMessageText . "\r\n\r\n";
  514.  
  515.         unless (print MYSOCKET $sTextMultipart)    # text content
  516.             {
  517.             $sLocalError = GetPhrase(-1, 18, 13, $!);    # Record internal error 
  518.             close MYSOCKET;
  519.             return($::FAILURE, $sLocalError, 0, 0);
  520.             }
  521.  
  522.         #
  523.         # send the HTML multipart 
  524.         #
  525.         my $sHTMLMultipart = "--" . $sBoundary . "\r\n";
  526.         $sHTMLMultipart .= "Content-Type: text/html; charset=us-ascii\r\n";
  527.         $sHTMLMultipart .= "Content-Transfer-Encoding: 7bit\r\n\r\n" . $sMessageHTML . "\r\n\r\n";
  528.  
  529.         unless (print MYSOCKET $sHTMLMultipart)    # HTML content
  530.             {
  531.             $sLocalError = GetPhrase(-1, 18, 14, $!);    # Record internal error 
  532.             close MYSOCKET;
  533.             return($::FAILURE, $sLocalError, 0, 0);
  534.             }
  535.  
  536.         #
  537.         # send the final boundary 
  538.         #
  539.         my $sEndMultipart = "--" . $sBoundary . "--\r\n";
  540.         unless (print MYSOCKET $sEndMultipart)        # multipart terminator
  541.             {
  542.             $sLocalError = GetPhrase(-1, 18, 15, $!);    # Record internal error 
  543.             close MYSOCKET;
  544.             return($::FAILURE, $sLocalError, 0, 0);
  545.             }
  546.         }
  547.     else
  548.         {
  549.         unless (print MYSOCKET "$sMessageText\r\n")    # just spacing
  550.             {
  551.             $sLocalError = GetPhrase(-1, 17, 6, $sMessage); # Record internal error 
  552.             close MYSOCKET;
  553.             return($::FAILURE, $sLocalError, 0, 0);
  554.             }
  555.         }
  556.     unless (print MYSOCKET "\r\n.\r\n")                # finish the message
  557.         {
  558.         $sLocalError = GetPhrase(-1, 18, 9, $!);    # Record internal error 
  559.         close MYSOCKET;
  560.         return($::FAILURE, $sLocalError, 0, 0);
  561.         }
  562.     
  563.     $sMessage = <MYSOCKET>;                                # see what the SMTP server has to say
  564.     if ($sMessage =~ /^[45]/)                            # check for failures
  565.         {
  566.         $sLocalError = GetPhrase(-1, 17, 7, $sMessage);    # Record internal error 
  567.         close MYSOCKET;
  568.         return($::FAILURE, $sLocalError, 0, 0);
  569.         }
  570.     
  571.     unless (print MYSOCKET "QUIT\r\n")                    # end the conversation
  572.         {
  573.         $sLocalError = GetPhrase(-1, 18, 10, $!);    # Record internal error 
  574.         close MYSOCKET;
  575.         return($::FAILURE, $sLocalError, 0, 0);
  576.         }
  577.     
  578.     $sMessage = <MYSOCKET>;                                # see what the SMTP server has to say
  579.     if ($sMessage =~ /^[45]/)                            # check for failures
  580.         {
  581.         $sLocalError = GetPhrase(-1, 17, 8, $sMessage);    # Record internal error 
  582.         close MYSOCKET;
  583.         return($::FAILURE, $sLocalError, 0, 0);
  584.         }
  585.     
  586.     shutdown MYSOCKET, 1;                                # shutdown sends
  587.     close MYSOCKET;                                        # done
  588.     
  589.     return($::SUCCESS, '', 0, 0);
  590.     }
  591.  
  592. #######################################################
  593. #                                                                        
  594. # GetCookie - retrieve the actinic cookie
  595. #
  596. # Returns:    0 - cookie (undef if undefined)
  597. #
  598. #######################################################
  599.  
  600. sub GetCookie
  601.     {
  602.     my ($sCartID, $sContactDetails) = GetCookies();
  603.     return ($sCartID);
  604.     }
  605.     
  606. #######################################################
  607. #                                                                        
  608. # GetCookies - retrieve the actinic cookies
  609. #
  610. # Returns:    0 - cart ID (undef if undefined)
  611. #                1 - checkout details (undef if undefined)
  612. #
  613. #######################################################
  614.  
  615. sub GetCookies
  616.     {
  617.     my ($sCookie, $sCookies);
  618.     $sCookies = $::ENV{'HTTP_COOKIE'};                # try to retrieve the cookie
  619.     my (@CookieList) = split(/;/, $sCookies);        # separate the various cookie variables in the list
  620.     my ($sLabel);
  621.     my $bFound = $::FALSE;                                # true when one of the cookies has been found
  622.     my ($sCartID, $sContactDetails);
  623.     foreach $sCookie (@CookieList)
  624.         {
  625.         $sCookie =~ s/^\s*//;                            # strip leading white space
  626.         if ($sCookie =~ /^ACTINIC_CART/)                # found the cart ID
  627.             {
  628.             ($sLabel, $sCartID) = split (/=/, $sCookie);    # retrieve the value
  629.             #
  630.             # Make the cart ID secure by locking out any shell type characters
  631.             #
  632.             $sCartID =~ /([a-zA-Z0-9]+)/;                # cart ID's are just characters
  633.             $sCartID = $1;
  634.  
  635.             if ($bFound)                                    # if the other cookie has already been found
  636.                 {
  637.                 last;                                            # exit the loop
  638.                 }
  639.             else                                                # this is the first of the two cookies to be found
  640.                 {
  641.                 $bFound = $::TRUE;                        # note that we found it
  642.                 }
  643.             }
  644.         elsif ($sCookie =~ /^ACTINIC_CONTACT/)        # found the contact details
  645.             {
  646.             ($sLabel, $sContactDetails) = split (/=/, $sCookie);    # retrieve the value
  647.             #
  648.             # strip any trailing or leading quotes and spaces
  649.             #
  650.             $sContactDetails =~ s/^\s*"?//;        # " # here for emacs formatting
  651.             $sContactDetails =~ s/"?\s*$//;        # " # here for emacs formatting
  652.  
  653.             if ($bFound)                                    # if the other cookie has already been found
  654.                 {
  655.                 last;                                            # exit the loop
  656.                 }
  657.             else                                                # this is the first of the two cookies to be found
  658.                 {
  659.                 $bFound = $::TRUE;                        # note that we found it
  660.                 }
  661.             }
  662.         }
  663.     return ($sCartID, $sContactDetails);
  664.     }
  665.     
  666. #######################################################
  667. #                                                                        
  668. # GetReferrer - retrieve the referrer URL
  669. #
  670. # Returns:    0 - referring URL
  671. #
  672. #######################################################
  673.  
  674. sub GetReferrer
  675.     {
  676. #? ACTINIC::ASSERT(defined %::g_InputHash, "g_InputHash is undefined in GetReferrer", __LINE__, __FILE__);
  677.     my ($sURL);
  678.     $sURL = $::ENV{"HTTP_REFERER"};                    # try to retrieve the cookie
  679.     if (defined %::g_InputHash &&
  680.          defined $::g_InputHash{ACTINIC_REFERRER})
  681.         {
  682.         $sURL = $::g_InputHash{ACTINIC_REFERRER};
  683.         }
  684.     return ($sURL);
  685.     }
  686.  
  687. #######################################################
  688. #                                                                        
  689. # TrimHashEntries - trim leading and trailing white
  690. #    space from every value in the hash table
  691. #
  692. # Params:    0 - in/out - pointer to the hash
  693. #
  694. #######################################################
  695.  
  696. sub TrimHashEntries
  697.     {
  698. #? ACTINIC::ASSERT(0 == $#_, "Invalid parameter count in TrimHashEntries, $#_", __LINE__, __FILE__);
  699.     my $pHash = $_[0];
  700.     #
  701.     # process each entry in the hash
  702.     #
  703.     my ($key, $value);
  704.     while ( ($key, $value) = each %$pHash)
  705.         {
  706.         $$pHash{$key} =~ s/^\s*(.*?)\s*$/$1/gs;
  707.         }
  708.     }
  709.  
  710. ##################################################################################
  711. #                                                                                                            #
  712. # HTML manipulation functions - begin                                                            #
  713. #                                                                                                            #
  714. ##################################################################################
  715.  
  716. #######################################################
  717. #                                                                        
  718. # ProcessEscapableText - encode the text from the
  719. #    specified string leaving escaped regions raw.
  720. #
  721. # Params:    0 - the string to convert
  722. #
  723. # Returns:    0 - status
  724. #                1 - modified string or error message (if any)
  725. #                2 - 0
  726. #                3 - 0
  727. #
  728. #######################################################
  729.  
  730. sub ProcessEscapableText
  731.     {
  732. #? ACTINIC::ASSERT($#_ == 0, "Invalid argument count in ProcessEscapableText ($#_)", __LINE__, __FILE__);
  733.  
  734.     my ($sString) = @_;
  735.     #
  736.     # first see if there is any escaped text
  737.     #
  738.     my (@Response);
  739.     if ($sString !~ /!!</)                                # no escaped text
  740.         {
  741.         return (EncodeText($sString));                # encode it
  742.         }
  743.     #
  744.     # pick apart the string
  745.     #
  746.     my (@PartsList) = ($sString =~  m/((.*?)!!<(.*?)>!!)*/g);
  747.     my ($sEndPart) = ($sString =~ m/>!!(.*?)$/g); # get the closing encode text
  748.     #
  749.     # Now @PartsList contains a series of segments of the following pattern:
  750.     #
  751.     #        element        description
  752.     #            0            the entire segment - throw out
  753.     #            1            text to encode
  754.     #            2            raw HTML
  755.     #
  756.     my ($sPart, $sNewString, $nCount, $nElement);
  757.     $nCount = 0;
  758.     foreach $sPart (@PartsList)
  759.         {
  760.         $nElement = Modulus($nCount, 3);            # calculate the element number
  761.         
  762.         if ($nElement == 0)                                # the entire segment
  763.             {
  764.             # no-op - throw out
  765.             }
  766.         elsif ($nElement == 1)                            # text to be encoded
  767.             {
  768.             @Response = EncodeText($sPart);            # encode it
  769.             if ($Response[0] != $::SUCCESS)
  770.                 {
  771.                 return (@Response);
  772.                 }
  773.             $sNewString .= $Response[1];
  774.             }
  775.         elsif ($nElement == 2)                            # raw HTML
  776.             {
  777.             $sNewString .= $sPart;
  778.             }
  779.         $nCount++;
  780.         }
  781.     #
  782.     # the end part needs to be encoded and included
  783.     #
  784.     @Response = EncodeText($sEndPart);                # encode it
  785.     if ($Response[0] != $::SUCCESS)
  786.         {
  787.         return (@Response);
  788.         }
  789.     $sNewString .= $Response[1];                        # and include it
  790.     
  791.     return ($::SUCCESS, $sNewString, 0, 0);
  792.     }
  793.     
  794. #######################################################
  795. #                                                                        
  796. # EncodeText2 - convert then non-alphanumeric characters in
  797. #    the supplied string to &#xx; where xx is the
  798. #    equivalent decimal code for the character.  This is
  799. #    needed for the HTML printout
  800. #
  801. # Params:    0 - the string to convert
  802. #                1 - (optional) if TRUE, do HTML encoding (&#d;)
  803. #                    if FALSE, do CGI encodeing (%x).  Default - TRUE
  804. #                2 - (optional) if TRUE make spaces  ,
  805. #                    default - FALSE.  Only makes sense in
  806. #                    the context of 1 = TRUE
  807. #
  808. # Returns:    0 - modified string
  809. #
  810. #######################################################
  811.  
  812. sub EncodeText2
  813.     {
  814.     #
  815.     # !!!!!! This is a function commonly used by many utilities.  Any changes to its interface will
  816.     # !!!!!! need to be verified with the various utility scripts.
  817.     #
  818.     
  819.     my @Response = EncodeText(@_);
  820. #? ACTINIC::ASSERT($Response[0] == $::SUCCESS, "It looks like EncodeText can return an error.", __LINE__, __FILE__);
  821.     return ($Response[1]);
  822.     }
  823.     
  824. #######################################################
  825. #                                                                        
  826. # EncodeText - convert then non-alphanumeric characters in
  827. #    the supplied string to &#xx; where xx is the
  828. #    equivalent decimal code for the character.  This is
  829. #    needed for the HTML printout
  830. #
  831. # Params:    0 - the string to convert
  832. #                1 - (optional) if TRUE, do HTML encoding (&#d;)
  833. #                    if FALSE, do CGI encodeing (%x).  Default - TRUE
  834. #                2 - (optional) if TRUE make spaces  ,
  835. #                    default - FALSE.  Only makes sense in
  836. #                    the context of 1 = TRUE
  837. #
  838. # Returns:    0 - status
  839. #                1 - modified string or error message (if any)
  840. #                2 - 0
  841. #                3 - 0
  842. #
  843. #######################################################
  844.  
  845. sub EncodeText
  846.     {
  847. #? ACTINIC::ASSERT($#_ >= 0, "Invalid argument count in EncodeText ($#_)", __LINE__, __FILE__);
  848.     
  849.     #
  850.     # !!!!!! This is a function commonly used by many utilities.  Any changes to its interface will
  851.     # !!!!!! need to be verified with the various utility scripts.
  852.     #
  853.     
  854.     my ($sString, $bHtmlEncoding, $bNBSP) = @_;
  855.     if (!defined $bHtmlEncoding)                        # default encoding is HTML
  856.         {
  857.         $bHtmlEncoding = $::TRUE;
  858.         }
  859.     if (!defined $bNBSP)                                    # default NBSP is FALSE
  860.         {
  861.         $bNBSP = $::FALSE;
  862.         }
  863.     #
  864.     # Do the substitution.
  865.     #
  866.     if ($bHtmlEncoding)                                    # HTML encoding
  867.         {
  868.         $sString =~ s/(\W)/sprintf('&#%d;', ord($1))/eg;    # regular space substitution
  869.         }
  870.     else                                                        # CGI encoding
  871.         {
  872.         $sString =~ s/(\W)/sprintf('%%%2.2x', ord($1))/eg;    # regular space substitution
  873.         }
  874.     
  875.     if ($bNBSP)                                                # if we want non-breaking spaces
  876.         {
  877.         $sString =~ s/ / /g;                    # replace the normal spaces with the non-breaking versions
  878.         }                                                        # NOTE: this does nothing if ! $bHtmlEncoding
  879.         
  880.     return ($::SUCCESS, $sString, 0, 0);
  881.     }
  882.  
  883. #######################################################
  884. #                                                                        
  885. # DecodeText - this function is similar
  886. #    to EncodeText with two exceptions: 1) it deals with
  887. #    characters stored as %xx and 2) it works in reverse
  888. #    restoring the character for the % value
  889. #
  890. # Params:    0 - the string to convert
  891. #                1 - decode method flag $ACTINIC::FORM_URL_ENCODED or $ACTINIC::MODIFIED_FORM_URL_ENCODED
  892. #                    $ACTINIC::FORM_URL_ENCODED = decode using application/x-www-form-urlencoded (%xx)
  893. #                    $ACTINIC::MODIFIED_FORM_URL_ENCODED = Actinic format - identical to $::FORM_URL_ENCODED except an
  894. #                        underscore is used instead of a percent sign and the string is
  895. #                        prepended with an "a".  This encoding is used to map arbitrary
  896. #                        strings into HTML "ID and NAME" data types.
  897. #                        NAME tokens must begin with a letter ([A-Za-z]) and may be
  898. #                        followed by any number of letters, digits ([0-9]), hyphens ("-"),
  899. #                        underscores ("_"), colons (":"), and periods (".")
  900. #
  901. # Returns:    ($sString) - the converted string
  902. #
  903. #######################################################
  904.  
  905. sub DecodeText
  906.     {
  907. #? ACTINIC::ASSERT($#_ == 1, "Invalid argument count in DecodeText ($#_)", __LINE__, __FILE__);
  908.  
  909.     #
  910.     # !!!!!! This is a function commonly used by many utilities.  Any changes to its interface will
  911.     # !!!!!! need to be verified with the various utility scripts.
  912.     #
  913.     
  914.     my ($sString, $eEncoding) = @_;
  915.     
  916.     if ($eEncoding == $ACTINIC::MODIFIED_FORM_URL_ENCODED)
  917.         {
  918.         $sString =~ s/^a//;                                # string the leading a
  919.         $sString =~ s/_([A-Fa-f0-9]{2})/pack('c',hex($1))/ge;    # Convert _XX from hex numbers to character equivalent
  920.         }
  921.     elsif ($eEncoding == $ACTINIC::FORM_URL_ENCODED)
  922.         {
  923.         $sString =~ s/\+/ /g;                            # replace + signs with the spaces they represent        
  924.         $sString =~ s/%([A-Fa-f0-9]{2})/pack('c',hex($1))/ge;    # Convert %XX from hex numbers to character equivalent
  925.         }
  926.     else
  927.         {
  928. #? ACTINIC::ASSERT($::FALSE, 'Invalid encodgin argument to DecodeText' . " ($eEncoding)", __LINE__, __FILE__);
  929.         }
  930.     
  931.     return ($sString);
  932.     }
  933.  
  934. #######################################################
  935. #                                                                        
  936. # TemplateFile - replace the vars in the template file
  937. #    with the values stored in the variable table
  938. #
  939. # Params:    0 - template filename
  940. #                1 - a reference to the variable table
  941. #
  942. # Returns:  0 - $::SUCCESS or $::FAILURE on error
  943. #                1 - error message
  944. #                2 - modified HTML
  945. #                3 - 0
  946. #
  947. #######################################################
  948.  
  949. sub TemplateFile
  950.     {
  951. #? ACTINIC::ASSERT($#_ >= 0, "Invalid argument count in TemplateFile ($#_)", __LINE__, __FILE__);
  952.     
  953.     #
  954.     # !!!!!! This is a function commonly used by many utilities.  Any changes to its interface will
  955.     # !!!!!! need to be verified with the various utility scripts.
  956.     #
  957.     
  958.     my ($sFilename, $pVariableTable);
  959.     ($sFilename, $pVariableTable) = @_;
  960.     
  961.     unless (open (TFFILE, "<$sFilename"))
  962.         {
  963.         return($::FAILURE, GetPhrase(-1, 21, $sFilename, $!), '', 0);
  964.         }
  965.         
  966.     my ($sOutput);
  967.     {
  968.     local $/;
  969.     $sOutput = <TFFILE>;                                # read the entire file
  970.     }
  971.     close (TFFILE);
  972.     
  973.     return (TemplateString($sOutput, $pVariableTable));
  974.     }
  975.  
  976. #######################################################
  977. #                                                                        
  978. # TemplateString - replace the vars in the template
  979. #    string with their values
  980. #
  981. # Params:    0 - template string
  982. #                1 - a reference to the variable table
  983. #
  984. # Returns:  0 - $::SUCCESS or $::FAILURE on error
  985. #                1 - error message
  986. #                2 - modified HTML
  987. #                3 - 0
  988. #
  989. #######################################################
  990.  
  991. sub TemplateString
  992.     {
  993. #? ACTINIC::ASSERT($#_ == 1, "Invalid argument count in TemplateString ($#_)", __LINE__, __FILE__);
  994.     
  995.     #
  996.     # !!!!!! This is a function commonly used by many utilities.  Any changes to its interface will
  997.     # !!!!!! need to be verified with the various utility scripts.
  998.     #
  999.     
  1000.     my ($sString, $pVariableTable);
  1001.     ($sString, $pVariableTable) = @_;
  1002.     
  1003.     if(defined $$pVariableTable{'NETQUOTEVAR:ADVANCEDTAXHTML'})
  1004.         {
  1005.         my %hashEmpty = {};
  1006.         my @Response = TemplateFile(GetPath()."advancedtax.html", \%hashEmpty);
  1007.         if ($Response[0] != $::SUCCESS)
  1008.             {
  1009.             return (@Response);
  1010.             }
  1011.         $sString =~ s/(NETQUOTEDEL:TAXPHASE)(.*?)NETQUOTEVAR:TAXPROMPT.*?NETQUOTEDEL:TAXPHASE/$1$Response[2]$1/isg;                # replace the variable with its value
  1012.         delete $$pVariableTable{'NETQUOTEVAR:ADVANCEDTAXHTML'};
  1013.         }
  1014.  
  1015.     my ($key, $value);
  1016.     while (($key, $value) = each %$pVariableTable)# for every variable in the table
  1017.         {
  1018.         $sString =~ s/$key/$value/isg;                # replace the variable with its value
  1019.         }
  1020.     
  1021.     return ($::SUCCESS, '', $sString, 0);
  1022.     }
  1023.  
  1024. #######################################################
  1025. #                                                                        
  1026. # ReturnToLastPage - bounce the browser to the previous
  1027. #    page
  1028. #
  1029. # Params:    0 - bounce delay (if less than 0, don't
  1030. #                    automatically bounce)
  1031. #                1 - string to add to display
  1032. #                2 - optional page title.  If the page
  1033. #                        title exists (ne ''), the page is formatted
  1034. #                        using the bounce template
  1035. #                3 - pointer to the page list
  1036. #                4 - the refering site URL
  1037. #                5 - content site URL
  1038. #                6 - pointer to the setup blob
  1039. #                7+ - InputHash table
  1040. #
  1041. # Returns:    0 - status
  1042. #                1 - error message
  1043. #                2 - HTML for the bounce page
  1044. #
  1045. #######################################################
  1046.  
  1047. sub ReturnToLastPage
  1048.     {
  1049. #? ACTINIC::ASSERT($#_ > 7, "Invalid argument count in ReturnToLastPage ($#_)", __LINE__, __FILE__);
  1050.     
  1051.     if ($_[1] ne '')                                        # if the page title is defined, format the page prettily
  1052.         {
  1053.         return (ReturnToLastPageEnhanced(@_));
  1054.         }
  1055.     else                                                        # otherwise, use a plain page
  1056.         {
  1057.         return (ReturnToLastPagePlain(@_));
  1058.         }
  1059.     }
  1060.  
  1061. #######################################################
  1062. #                                                                        
  1063. # GroomError - make the error look nice for the HTML
  1064. #
  1065. # Params:    0 - Error string
  1066. #
  1067. # Returns:    0 - pretty string
  1068. #
  1069. #######################################################
  1070.  
  1071. sub GroomError
  1072.     {
  1073.     if ($#_ != 0)
  1074.         {
  1075.         return (GroomError(ACTINIC::GetPhrase(-1, 12, 'GroomError')));
  1076.         }
  1077.     my ($sError) = @_;
  1078.  
  1079.     if ($sError eq "")
  1080.         {
  1081.         return ($sError);
  1082.         }
  1083.  
  1084.     $sError = "<TABLE CELLPADDING=\"10\" WIDTH=\"550\" BORDER=\"1\" BGCOLOR=\"$$::g_pSetupBlob{FORM_BACKGROUND_COLOR}\">" .
  1085.         "<TR><TD><BIG> $sError</BIG></TD></TR></TABLE><P><HR>";
  1086.  
  1087.     return ($sError);
  1088.     }
  1089.  
  1090. #######################################################
  1091. #                                                                        
  1092. # GroomHTML - Display HTML in catalog style
  1093. #    NOTE: this is a wrapper for the ACTINIC
  1094. #    package version.  It prevents a bunch of duplicate
  1095. #    work
  1096. #
  1097. # Params:    [0] - string to add to display
  1098. #                [1] - optional page title.  If the page
  1099. #                        title exists, the page is formatted
  1100. #                        using the bounce template
  1101. #                2 - pointer to the page list
  1102. #                3 - the refering site URL
  1103. #                4 - content site URL
  1104. #                5 - pointer to the setup blob
  1105. #                6+ - InputHash table
  1106. #
  1107. # Expects:    %::g_InputHash should be defined
  1108. #
  1109. # Returns:    ($ReturnCode, $Error, $sHTML, 0)
  1110. #                if $ReturnCode = $::FAILURE, the operation failed
  1111. #                    for the reason specified in $Error
  1112. #                Otherwise everything is OK
  1113. #                $sHTML - the HTML of the page
  1114. #
  1115. #######################################################
  1116.  
  1117. sub GroomHTML
  1118.     {
  1119. #? ACTINIC::ASSERT($#_ > 6, "Invalid argument count in GroomHTML ($#_)", __LINE__, __FILE__);
  1120.  
  1121.     my ($sHTML, $sMessage, $sRefPage, $sScriptName);
  1122.     my (%InputHash, $temp, $pPageList, $sTitle, $pSetupBlob, $sContentUrl, $sWebSiteUrl);
  1123.     ($sMessage, $sTitle, $pPageList, $sWebSiteUrl, $sContentUrl, $pSetupBlob, %InputHash) = @_;
  1124.     
  1125.     pop @$pPageList;                                        # throw out the current page
  1126.     $sRefPage = pop @$pPageList;                        # get the previous page
  1127.             
  1128.     $sScriptName = GetScriptNameRegexp();
  1129.     if ($sRefPage =~ /$sScriptName/)                    # if the referring page was a script call,
  1130.         {
  1131.         #
  1132.         # get the page history - note that passing '' as the first argument guarantees tha prevquery will
  1133.         # be meaningless
  1134.         #
  1135.         my ($status, $sMessage, $sPrevQuery, $sPageHistory) = PrepareRefPageData('', $pPageList, $::TRUE);
  1136.         if ($status != $::SUCCESS)
  1137.             {
  1138.             return($status, $sMessage, '');
  1139.             }
  1140.         #
  1141.         # tack the "END" on so ReadAndParseInput knows this was a bounce
  1142.         #
  1143.         $sRefPage .= '&' . "REFPAGE=" . $sPageHistory . "END";        # this must be the last thing in the query statement
  1144.         }
  1145.     
  1146.     return (GroomHTMLEnhanced($sMessage, $sTitle, $pPageList,
  1147.         $sWebSiteUrl, $sContentUrl, $pSetupBlob, $sRefPage, \%InputHash));
  1148.     }
  1149.  
  1150. #######################################################
  1151. #                                                                        
  1152. # GroomHTMLEnhanced - Format the page contents using
  1153. #    the bounce.html template
  1154. #
  1155. # Params:    0 - string to add to display
  1156. #                0 - optional page title.  If the page
  1157. #                        title exists (ne ''), the page is formatted
  1158. #                        using the bounce template
  1159. #                2 - pointer to the page list
  1160. #                3 - the refering site URL
  1161. #                4 - content site URL
  1162. #                5 - pointer to the setup blob
  1163. #                6 - the page to go to
  1164. #                7 - pointer to InputHash table
  1165. #
  1166. # Returns:    0 - status
  1167. #                1 - error message
  1168. #                2 - HTML for the page
  1169. #
  1170. #######################################################
  1171.  
  1172. sub GroomHTMLEnhanced
  1173.     {
  1174. #? ACTINIC::ASSERT($#_ > 6, "Invalid argument count in GroomHTMLEnhanced ($#_)", __LINE__, __FILE__);
  1175.     my ($sHTML, $sMessage, $sScriptName);
  1176.     my ($pInputHash, $temp, $pPageList, $sTitle, $pSetupBlob, $sWebSiteUrl, $sContentUrl, $sRefPage);
  1177.     ($sMessage, $sTitle, $pPageList, $sWebSiteUrl, $sContentUrl, $pSetupBlob, , $sRefPage, $pInputHash) = @_;
  1178.     
  1179.     my ($sPath, @Response, $Status, $Message);
  1180.     $sPath = GetPath();                                    # get the path to the web site dir
  1181.     
  1182.     my (%VariableTable);
  1183.     $VariableTable{$::VARPREFIX."BOUNCETITLE"} = $sTitle; # add the title to the var list
  1184.     $VariableTable{$::VARPREFIX."BOUNCEMESSAGE"} = $sMessage; # add the message to the var list
  1185.     
  1186.     @Response = TemplateFile($sPath."bounce.html", \%VariableTable); # make the substitutions
  1187.     ($Status, $Message, $sHTML) = @Response;
  1188.     if ($Status != $::SUCCESS)
  1189.         {
  1190.         return (@Response);
  1191.         }
  1192.     
  1193.     #######
  1194.     # make the file references point to the correct directory
  1195.     #######
  1196.     @Response = MakeLinksAbsolute($sHTML, $sWebSiteUrl, $sContentUrl);
  1197.     ($Status, $Message, $sHTML) = @Response;
  1198.     if ($Status != $::SUCCESS)
  1199.         {
  1200.         return (@Response);
  1201.         }
  1202.     
  1203.     return ($::SUCCESS, '', $sHTML, 0);
  1204.     }
  1205.  
  1206. #######################################################
  1207. #                                                                        
  1208. # ReturnToLastPagePlain - bounce the browser to the
  1209. #    previous page using a plain white page
  1210. #
  1211. # Params:    0 - bounce delay (if less than 0, don't
  1212. #                    automatically bounce)
  1213. #                1 - string to add to display
  1214. #                2 - optional page title.  If the page
  1215. #                        title exists (ne ''), the page is formatted
  1216. #                        using the bounce template
  1217. #                3 - pointer to the page list
  1218. #                4 - the refering site URL
  1219. #                5 - content site URL
  1220. #                6 - pointer to the setup blob
  1221. #                7+ - InputHash table
  1222. #
  1223. # Returns:    0 - status
  1224. #                1 - error message
  1225. #                2 - HTML for the bounce page
  1226. #
  1227. #######################################################
  1228.  
  1229. sub ReturnToLastPagePlain
  1230.     {
  1231. #? ACTINIC::ASSERT($#_ > 7, "Invalid argument count in ReturnToLastPagePlain ($#_)", __LINE__, __FILE__);
  1232.     my ($sHTML, $nDelay, $sMessage, $sRefPage, $sScriptName, %InputHash, $temp, $pPageList, $sWebSiteUrl, $sContentUrl, $pSetupBlob);
  1233.     ($nDelay, $sMessage, $temp, $pPageList, $sWebSiteUrl, $sContentUrl, $pSetupBlob, %InputHash) = @_;
  1234.     
  1235.     pop @$pPageList;                                        # throw out the current page
  1236.     $sRefPage = pop @$pPageList;                        # get the previous page
  1237.     
  1238.     $sScriptName = GetScriptNameRegexp();
  1239.     if ($sRefPage =~ /$sScriptName/)                    # if the referring page was a script call,
  1240.         {
  1241.         #
  1242.         # get the page history - note that passing '' as the first argument guarantees tha prevquery will
  1243.         # be meaningless
  1244.         #
  1245.         my ($status, $sMessage, $sPrevQuery, $sPageHistory) = PrepareRefPageData('', $pPageList, $::TRUE);
  1246.         if ($status != $::SUCCESS)
  1247.             {
  1248.             return($status, $sMessage, '');
  1249.             }
  1250.         #
  1251.         # tack the "END" on so ReadAndParseInput knows this was a bounce
  1252.         #
  1253.         $sRefPage .= '&' . "REFPAGE=" . $sPageHistory . "END";        # this must be the last thing in the query statement
  1254.         }
  1255.         
  1256.     return (BounceToPagePlain($nDelay, $sMessage, $temp, $pPageList,
  1257.         $sWebSiteUrl, $sContentUrl, $pSetupBlob, $sRefPage, \%InputHash));
  1258.     }
  1259.  
  1260. #######################################################
  1261. #                                                                        
  1262. # BounceToPagePlain - bounce the browser to the
  1263. #    specified page using a simple page
  1264. #
  1265. # Params:    0 - bounce delay (if less than 0, don't
  1266. #                    automatically bounce)
  1267. #                1 - string to add to display
  1268. #                2 - optional page title.  If the page
  1269. #                        title exists (ne ''), the page is formatted
  1270. #                        using the bounce template
  1271. #                3 - pointer to the page list
  1272. #                4 - the refering site URL
  1273. #                5 - content site URL
  1274. #                6 - pointer to the setup blob
  1275. #                7 - URL to go to
  1276. #                8 - InputHash table
  1277. #                9 - clear frames flag - if $::TRUE,
  1278. #                   clear any existing
  1279. #                    frames when bouncing.   Default: $::FALSE
  1280. #
  1281. # Returns:    0 - status
  1282. #                1 - error message
  1283. #                2 - HTML for the bounce page
  1284. #
  1285. #######################################################
  1286.  
  1287. sub BounceToPagePlain
  1288.     {
  1289. #? ACTINIC::ASSERT($#_ > 7, "Wrong number of arguments in BounceToPagePlain ($#_)", __LINE__, __FILE__);
  1290.  
  1291.     my ($sHTML, $nDelay, $sMessage, $sRefPage, $sScriptName, $pInputHash);
  1292.     my ($temp, $pPageList, $sWebSiteUrl, $sContentUrl, $pSetupBlob, $bClearFrames);
  1293.     ($nDelay, $sMessage, $temp, $pPageList, $sWebSiteUrl, $sContentUrl, $pSetupBlob, $sRefPage, $pInputHash, $bClearFrames) = @_;
  1294.     #
  1295.     # set the flag to clear the flag if it exists and clearing was requested
  1296.     #
  1297. #    $bClearFrames = $bClearFrames;                    # What is this for?
  1298.             
  1299.     my ($sDigest,$sBaseFile) = ACTINIC::CaccGetCookies();
  1300.     if( !$sDigest )
  1301.         {
  1302.         $sWebSiteUrl = $sContentUrl;
  1303.         }
  1304.     else
  1305.         {
  1306.         $sWebSiteUrl = $sBaseFile;
  1307.         $sWebSiteUrl =~ s#/[^/]*$#/#;
  1308.         }
  1309.     if ($sRefPage eq '')                                    # if no referring page, ask the user to manually return
  1310.         {
  1311.         $sHTML = "<HTML>\n";                                # open page
  1312.         $sHTML .= "<BODY";                                # body definition
  1313.         if ($$pSetupBlob{'BACKGROUND_IS_IMAGE'} &&
  1314.              length $$pSetupBlob{'BACKGROUND_VALUE'} > 0)
  1315.             {
  1316.             $sHTML .= " BACKGROUND=\"" . $sWebSiteUrl . $$pSetupBlob{'BACKGROUND_VALUE'} . "\"";
  1317.             }
  1318.         elsif (length $$pSetupBlob{'BACKGROUND_VALUE'} > 0)
  1319.             {
  1320.             $sHTML .= " BGCOLOR=\"" . $$pSetupBlob{'BACKGROUND_VALUE'} . "\"";
  1321.             }
  1322.         if (length $$pSetupBlob{'FOREGROUND_COLOR'} > 0)
  1323.             {
  1324.             $sHTML .= " TEXT=\"" . $$pSetupBlob{'FOREGROUND_COLOR'} . "\""
  1325.             }
  1326.         if (length $$pSetupBlob{'LINK_COLOR'} > 0)
  1327.             {
  1328.             $sHTML .= " LINK=\"" . $$pSetupBlob{'LINK_COLOR'} . "\""
  1329.             }
  1330.         if (length $$pSetupBlob{'ALINK_COLOR'} > 0)
  1331.             {
  1332.             $sHTML .= " ALINK=\"" . $$pSetupBlob{'ALINK_COLOR'} . "\""
  1333.             }
  1334.         if (length $$pSetupBlob{'VLINK_COLOR'} > 0)
  1335.             {
  1336.             $sHTML .= " VLINK=\"" . $$pSetupBlob{'VLINK_COLOR'} . "\""
  1337.             }
  1338.         $sHTML .= "><BLOCKQUOTE>\n";
  1339.         $sHTML .= $sMessage."<P>\n";                    # add the call specific message (if any)
  1340.         $sHTML .= GetPhrase(-1, 22) . "<BR></BLOCKQUOTE>\n";
  1341.         }
  1342.     else                                                        # bounce to the referring page
  1343.         {
  1344.         $sHTML = "<HTML>\n";                                # open page
  1345.         if( $$pInputHash{MAINFRAMEURL} and $sRefPage =~ /\?/ )    # For parsed frameset we may change main frame URL
  1346.             {
  1347.             $sRefPage .= "$`" . '?MAINFRAMEURL=' . $$pInputHash{MAINFRAMEURL} . "\&$'";
  1348.             }
  1349.         if ($nDelay >= 0)                                    # only try to auto bounce if the delay is a positive number
  1350.             {
  1351.             my $sMetaTag;
  1352.             if ($bClearFrames)                            # use JavaScript to clear frames on the auto-bounce
  1353.                 {
  1354.                 $sMetaTag =
  1355.                     "<SCRIPT LANGUAGE=\"JAVASCRIPT\">\n" . 
  1356.                     "<!-- hide from older browsers\n" .
  1357.                     "setTimeout(\"ForwardPage()\", " . 1000 * $nDelay . ");\n" .
  1358.                     "function ForwardPage()\n" .
  1359.                     "    {\n" .
  1360.                     "    parent.location.replace('$sRefPage');\n" .
  1361.                     "    }\n" .
  1362.                     "// -->\n" .
  1363.                     "</SCRIPT>\n";
  1364.                 }
  1365.             else                                                # no need for the JavaScript, so use the more commonly supported Meta tag
  1366.                 {
  1367.                 $sMetaTag = "<META HTTP-EQUIV=\"refresh\" "; # refresh message
  1368.                 $sMetaTag .= "CONTENT=\"$nDelay; URL=".$sRefPage."\">\n";
  1369.                 }
  1370.             $sHTML .= $sMetaTag;
  1371.             }
  1372.         
  1373.         $sHTML .= "<BODY";                                # body definition
  1374.         if ($$pSetupBlob{'BACKGROUND_IS_IMAGE'} &&
  1375.              length $$pSetupBlob{'BACKGROUND_VALUE'} > 0)
  1376.             {
  1377.             $sHTML .= " BACKGROUND=\"" . $sWebSiteUrl . $$pSetupBlob{'BACKGROUND_VALUE'} . "\"";
  1378.             }
  1379.         elsif (length $$pSetupBlob{'BACKGROUND_VALUE'} > 0)
  1380.             {
  1381.             $sHTML .= " BGCOLOR=\"" . $$pSetupBlob{'BACKGROUND_VALUE'} . "\"";
  1382.             }
  1383.         if (length $$pSetupBlob{'FOREGROUND_COLOR'} > 0)
  1384.             {
  1385.             $sHTML .= " TEXT=\"" . $$pSetupBlob{'FOREGROUND_COLOR'} . "\""
  1386.             }
  1387.         if (length $$pSetupBlob{'LINK_COLOR'} > 0)
  1388.             {
  1389.             $sHTML .= " LINK=\"" . $$pSetupBlob{'LINK_COLOR'} . "\""
  1390.             }
  1391.         if (length $$pSetupBlob{'ALINK_COLOR'} > 0)
  1392.             {
  1393.             $sHTML .= " ALINK=\"" . $$pSetupBlob{'ALINK_COLOR'} . "\""
  1394.             }
  1395.         if (length $$pSetupBlob{'VLINK_COLOR'} > 0)
  1396.             {
  1397.             $sHTML .= " VLINK=\"" . $$pSetupBlob{'VLINK_COLOR'} . "\""
  1398.             }
  1399.         $sHTML .= "><BLOCKQUOTE>\n";
  1400.         $sHTML .= $sMessage."<P>\n";                    # add the call specific message (if any)
  1401.         my $sBounceSentence;
  1402.         if ($nDelay >= 0)                                    # if the delay is a positive number
  1403.             {
  1404.             $sBounceSentence = GetPhrase(-1, 23, $sRefPage) . "\n"; # try to automatically bounce or here
  1405.             }
  1406.         else                                                    # negative delay means no auto bounce
  1407.             {
  1408.             $sBounceSentence = GetPhrase(-1, 161, $sRefPage) . "\n"; # click here to continue
  1409.             }
  1410.         #
  1411.         # if we are to clear the frames in the jump, add the target to this URL
  1412.         #
  1413.         if ($bClearFrames)
  1414.             {
  1415.             $sBounceSentence =~ s/(HREF=)/TARGET="_parent" $1/i;
  1416.             }
  1417.         #
  1418.         # add the message to the page
  1419.         #
  1420.         $sHTML .= $sBounceSentence . "<BLOCKQUOTE>";
  1421.         }
  1422.     $sHTML .= "</BODY>\n</HTML>\n";
  1423.     
  1424.     return ($::SUCCESS, '', $sHTML, 0);
  1425.     }
  1426.  
  1427. #######################################################
  1428. #                                                                        
  1429. # ReturnToLastPageEnhanced - bounce the browser to the
  1430. #    previous page, but format the page contents using
  1431. #    the bounce.html template
  1432. #
  1433. # Params:    0 - bounce delay (if less than 0, don't
  1434. #                    automatically bounce)
  1435. #                1 - string to add to display
  1436. #                2 - optional page title.  If the page
  1437. #                        title exists (ne ''), the page is formatted
  1438. #                        using the bounce template
  1439. #                3 - pointer to the page list
  1440. #                4 - the refering site URL
  1441. #                5 - content site URL
  1442. #                6 - pointer to the setup blob
  1443. #                7+ - InputHash table
  1444. #
  1445. # Returns:    0 - status
  1446. #                1 - error message
  1447. #                2 - HTML for the bounce page
  1448. #
  1449. #######################################################
  1450.  
  1451. sub ReturnToLastPageEnhanced
  1452.     {
  1453. #? ACTINIC::ASSERT($#_ > 7, "Invalid argument count in ReturnToLastPageEnhanced ($#_)", __LINE__, __FILE__);
  1454.     my ($sHTML, $nDelay, $sMessage, $sRefPage, $sScriptName);
  1455.     my (%InputHash, $temp, $pPageList, $sTitle, $sMetaTag, $pSetupBlob, $sContentUrl, $sWebSiteUrl);
  1456.     ($nDelay, $sMessage, $temp, $pPageList, $sWebSiteUrl, $sContentUrl, $pSetupBlob, %InputHash) = @_;
  1457.     
  1458.     pop @$pPageList;                                        # throw out the current page
  1459.     $sRefPage = pop @$pPageList;                        # get the previous page
  1460.  
  1461.     $sScriptName = GetScriptNameRegexp();
  1462.     if ($sRefPage =~ /$sScriptName/)                    # if the referring page was a script call,
  1463.         {
  1464.         #
  1465.         # get the page history - note that passing '' as the first argument guarantees tha prevquery will
  1466.         # be meaningless
  1467.         #
  1468.         my ($status, $sMessage, $sPrevQuery, $sPageHistory) = PrepareRefPageData('', $pPageList, $::TRUE);
  1469.         if ($status != $::SUCCESS)
  1470.             {
  1471.             return($status, $sMessage, '');
  1472.             }
  1473.         #
  1474.         # tack the "END" on so ReadAndParseInput knows this was a bounce
  1475.         #
  1476.         $sRefPage .= '&' . "REFPAGE=" . $sPageHistory . "END";        # this must be the last thing in the query statement
  1477.         }
  1478.     
  1479.     return (BounceToPageEnhanced($nDelay, $sMessage, $sTitle, $pPageList,
  1480.         $sWebSiteUrl, $sContentUrl, $pSetupBlob, $sRefPage, \%InputHash));
  1481.     }
  1482.  
  1483. #######################################################
  1484. #                                                                        
  1485. # BounceToPageEnhanced - bounce the browser to the
  1486. #    specified page, but format the page contents using
  1487. #    the bounce.html template
  1488. #
  1489. # Params:    0 - bounce delay (if less than 0, don't
  1490. #                    automatically bounce)
  1491. #                1 - string to add to display
  1492. #                2 - optional page title.  If the page
  1493. #                        title exists (ne ''), the page is formatted
  1494. #                        using the bounce template
  1495. #                3 - pointer to the page list
  1496. #                4 - the refering site URL
  1497. #                5 - content site URL
  1498. #                6 - pointer to the setup blob
  1499. #                7 - the page to go to
  1500. #                8 - pointer to InputHash table
  1501. #                9 - clear frames flag - if $::TRUE,
  1502. #                    clear any existing
  1503. #                    frames when bouncing.   Default: $::FALSE
  1504. #
  1505. # Returns:    0 - status
  1506. #                1 - error message
  1507. #                2 - HTML for the bounce page
  1508. #
  1509. #######################################################
  1510.  
  1511. sub BounceToPageEnhanced
  1512.     {
  1513. #? ACTINIC::ASSERT($#_ > 7, "Wrong number of arguments in BounceToPageEnhanced ($#_)", __LINE__, __FILE__);
  1514.     my ($sHTML, $nDelay, $sMessage, $sScriptName);
  1515.     my ($pInputHash, $temp, $pPageList, $sTitle, $sMetaTag, $pSetupBlob, $sWebSiteUrl, $sContentUrl, $sRefPage, $bClearFrames);
  1516.     ($nDelay, $sMessage, $sTitle, $pPageList, $sWebSiteUrl, $sContentUrl, $pSetupBlob, , $sRefPage, $pInputHash, $bClearFrames) = @_;
  1517.     #
  1518.     # set the flag to clear the flag if it exists and clearing was requested
  1519.     #
  1520.     #    $bClearFrames = $bClearFrames;                # I don't see what this is for (rz)
  1521.         
  1522.     if ($sRefPage eq '')                                    # if no referring page, ask the user to manually return
  1523.         {
  1524.         $sMessage .= "<P>\n";                            # add the bouncy message
  1525.         $sMessage .= GetPhrase(-1, 22) . "<BR>\n";
  1526.         $sMetaTag = '';                                    # no bounce command
  1527.         }
  1528.     else                                                        # bounce to the referring page
  1529.         {
  1530.         if( $$pInputHash{MAINFRAMEURL} and $sRefPage =~ /\?/ )    # For parsed frameset we may change main frame URL
  1531.             {
  1532.             $sRefPage .= "$`" . '?MAINFRAMEURL=' . $$pInputHash{MAINFRAMEURL} . "\&$'";
  1533.             }
  1534.         if ($nDelay >= 0)                                    # only try to auto bounce if the delay is a positive number
  1535.             {
  1536.             if ($bClearFrames)                            # use JavaScript to clear frames on the auto-bounce
  1537.                 {
  1538.                 $sMetaTag =
  1539.                     "<SCRIPT LANGUAGE=\"JAVASCRIPT\">\n" . 
  1540.                     "<!-- hide from older browsers\n" .
  1541.                     "setTimeout(\"ForwardPage()\", " . 1000 * $nDelay . ");\n" .
  1542.                     "function ForwardPage()\n" .
  1543.                     "    {\n" .
  1544.                     "    parent.location.replace('$sRefPage');\n" .
  1545.                     "    }\n" .
  1546.                     "// -->\n" .
  1547.                     "</SCRIPT>\n";
  1548.                 }
  1549.             else                                                # no need for the JavaScript, so use the more commonly supported Meta tag
  1550.                 {
  1551.                 $sMetaTag = "<META HTTP-EQUIV=\"refresh\" "; # refresh message
  1552.                 $sMetaTag .= "CONTENT=\"$nDelay; URL=".$sRefPage."\">\n";
  1553.                 }
  1554.             }
  1555.         
  1556.         $sMessage .= "<P>\n";                            # add the bouncy message
  1557.         my $sBounceSentence;
  1558.         if ($nDelay >= 0)                                    # if the delay is a positive number
  1559.             {
  1560.             $sBounceSentence = GetPhrase(-1, 23, $sRefPage) . "\n"; # try to automatically bounce or here
  1561.             }
  1562.         else                                                    # negative delay means no auto bounce
  1563.             {
  1564.             $sBounceSentence = GetPhrase(-1, 161, $sRefPage) . "\n"; # click here to continue
  1565.             }
  1566.         #
  1567.         # if we are to clear the frames in the jump, add the target to this URL
  1568.         #
  1569.         if ($bClearFrames)
  1570.             {
  1571.             $sBounceSentence =~ s/(HREF=)/TARGET="_parent" $1/i;
  1572.             }
  1573.             
  1574.         $sMessage .= $sBounceSentence;                # add the bounce line to the text
  1575.         }
  1576.     
  1577.     my ($sPath, @Response, $Status, $Message);
  1578.     $sPath = GetPath();                                    # get the path to the web site dir
  1579.  
  1580.     my (%VariableTable);
  1581.     $VariableTable{$::VARPREFIX."BOUNCETITLE"} = $sTitle; # add the title to the var list
  1582.     $VariableTable{$::VARPREFIX."BOUNCEMESSAGE"} = $sMessage; # add the message to the var list
  1583.     
  1584.     @Response = TemplateFile($sPath."bounce.html", \%VariableTable); # make the substitutions
  1585.     ($Status, $Message, $sHTML) = @Response;
  1586.     if ($Status != $::SUCCESS)
  1587.         {
  1588.         return (@Response);
  1589.         }
  1590.     
  1591.     #######
  1592.     # make the file references point to the correct directory
  1593.     #######
  1594.     my $smPath = $sContentUrl;
  1595.     my $sCgiUrl = $sWebSiteUrl;
  1596.     my ($sDigest,$sBaseFile) = ACTINIC::CaccGetCookies();
  1597.     if( $sDigest )
  1598.         {
  1599.         $smPath = ($sBaseFile) ? $sBaseFile : $sContentUrl;
  1600.         $sCgiUrl = $::g_sAccountScript;
  1601.         $sCgiUrl   .= $::g_InputHash{SHOP} ? '?SHOP=' . ACTINIC::EncodeText2($::g_InputHash{SHOP}, $::FALSE) . '&' : '?';
  1602.         $sCgiUrl   .= 'PRODUCTPAGE=' . $sRefPage;
  1603.         }
  1604.     @Response = MakeLinksAbsolute($sHTML, $sCgiUrl, $smPath);
  1605.     ($Status, $Message, $sHTML) = @Response;
  1606.     if ($Status != $::SUCCESS)
  1607.         {
  1608.         return (@Response);
  1609.         }
  1610.     
  1611.     my ($sSearchTag, $sReplaceTag);
  1612.     $sSearchTag = '</TITLE>';                            # the bounce meta tag comes immediately after the title
  1613.     $sReplaceTag = $sSearchTag . "\n" . $sMetaTag;
  1614.     
  1615.     $sHTML =~ s/$sSearchTag/$sReplaceTag/ig;        # insert the bounce meta tag
  1616.     
  1617.     return ($::SUCCESS, '', $sHTML, 0);
  1618.     }
  1619.  
  1620. #######################################################
  1621. #                                                                        
  1622. # UpdateDisplay - Print the HTML to the browser after
  1623. #    modifying it to keep the page refs in order
  1624. #
  1625. # Params:    0 - HTML
  1626. #                1 - the original CGI input string
  1627. #                2 - pointer to the page list
  1628. #               3 - Cookie (optional)
  1629. #                4 - cache flag (optional - default no-cache)
  1630. #                5 - contact details cookie (optional)
  1631. #
  1632. #######################################################
  1633.  
  1634. sub UpdateDisplay
  1635.     {
  1636. #? ACTINIC::ASSERT($#_ >= 2, "Invalid argument count in UpdateDisplay ($#_)", __LINE__, __FILE__);
  1637.     my ($sHTML, $OriginalInputData, $pPageList, $sCookie, $bNoCacheFlag, $sContactDetailsCookie) = @_;
  1638.     if (!defined $sCookie)                                # if the optional cookie was not supplied
  1639.         {
  1640.         $sCookie = '';                                        # set the cookie to empty
  1641.         }
  1642.     if (!defined $bNoCacheFlag)                        # default the cache flag to no cache
  1643.         {
  1644.         $bNoCacheFlag = $::TRUE;
  1645.         }
  1646.     
  1647.     ###
  1648.     # supply the page list
  1649.     ###
  1650.     my ($sSearch, $sReplace, $sPrefQuery);
  1651.     $sSearch = $::VARPREFIX."REFPAGE";
  1652.     
  1653.     my ($status, $sMessage, $sPrevQuery, $sPageHistory) = PrepareRefPageData($OriginalInputData, $pPageList, $::FALSE);
  1654.     if ($status != $::SUCCESS)
  1655.         {
  1656.         TerminalError($sMessage);
  1657.         }
  1658.     $sPageHistory =~ s/\|\|\|$//;                        # strip the trailing terminator
  1659.     $sReplace = "<INPUT TYPE=HIDDEN NAME=REFPAGE VALUE=\"$sPageHistory\">\n" .
  1660.     "<INPUT TYPE=HIDDEN NAME=PREVQUERY VALUE=\"$sPrevQuery\">\n"; # add the query string in case it
  1661.     # gets lost (some servers don't include it in the HTTP_REFERER)
  1662.     $sHTML =~ s/$sSearch/$sReplace/;                    # insert the page list
  1663.  
  1664.     #
  1665.     # add a random hidden parameter value to guarantee requeries
  1666.     #
  1667.     srand();
  1668.     my ($Random) = rand();
  1669.     $sHTML =~ s/NETQUOTEVAR:RANDOM/$Random/g;
  1670.     
  1671.     PrintPage($sHTML, $sCookie, $bNoCacheFlag, $sContactDetailsCookie);
  1672.     }
  1673.  
  1674. #######################################################
  1675. #
  1676. # PrintNonParsedHeader - print the non-parsed headers
  1677. #  Note that this function is separate from PrintHeader
  1678. #  because I didn't want to break access to PrintHeader
  1679. #  at such a late date.  This function should be called
  1680. #  when dynamic feedback is required.  Note that NT does
  1681. #  not respect nonparsed headers for dynamic update (even
  1682. #  under Apache).
  1683. #
  1684. #    Input:     0 - content type
  1685. #
  1686. #######################################################
  1687.  
  1688. sub PrintNonParsedHeader
  1689.     {
  1690. #? ACTINIC::ASSERT($#_ == 0, "Invalid argument count in PrintNonParsedHeader ($#_)", __LINE__, __FILE__);
  1691.     # 
  1692.    # Dump the HTTP headers so we can do proper non parsed header processing (for dynamic feedback)
  1693.    #
  1694.     $|=1;
  1695.     print $::ENV{SERVER_PROTOCOL} . " 200 OK\n";
  1696.     print "Server: " . $::ENV{SERVER_SOFTWARE} . "\n";
  1697.     print "Content-type: " . $_[0] . "\n";
  1698.    #
  1699.    # Build a date for the expiry
  1700.    #
  1701.     my ($day, $month, $now, $later, $expiry, @now, $sNow);
  1702.     my (@days) = ('Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat');
  1703.     my (@months) = ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');
  1704.     
  1705.     $now = time;
  1706.     @now = gmtime($now);
  1707.     $day = $days[$now[6]];
  1708.     $month = $months[$now[4]];
  1709.     $sNow = sprintf("%s, %02d %s %04d %02d:%02d:%02d GMT", $day, $now[3],
  1710.                          $month, $now[5]+1900, $now[2], $now[1], $now[0]);
  1711.  
  1712.     print "Date: $sNow\n\n";                            # print the date to allow the browser to compensate between server and client differences
  1713.     }
  1714.  
  1715. #######################################################
  1716. #
  1717. # PrintHeader - print the HTTP header
  1718. #
  1719. #    Params:     0 - content type
  1720. #                1 - content length
  1721. #                2 - cookie if any (or undef)
  1722. #                3 - no-cache flag - if $::TRUE,
  1723. #                    include no-cache flag.
  1724. #                4 - contact details cookie (optional)
  1725. #
  1726. # 3/11/99 - content type, length, date and nocache moved to the top
  1727. #        date made unconditional.    R. Zybert
  1728. #
  1729. #######################################################
  1730.  
  1731. sub PrintHeader
  1732.     {
  1733. #? ACTINIC::ASSERT($#_ >= 3, "Invalid argument count in PrintHeader ($#_)", __LINE__, __FILE__);
  1734.  
  1735.     #
  1736.     # !!!!!! This is a function commonly used by many utilities.  Any changes to its interface will
  1737.     # !!!!!! need to be verified with the various utility scripts.
  1738.     #
  1739.     
  1740.     my ($sType, $nLength, $sCookie, $bNoCache, $sContactDetailsCookie) = @_;
  1741.     #
  1742.     # Turn on non-parsed headers by default when running under IIS server and Doug MacEachern's modperl
  1743.     #
  1744.     my $bNPH = $::FALSE;
  1745.     if ( (defined($ENV{'SERVER_SOFTWARE'}) && $ENV{'SERVER_SOFTWARE'}=~/IIS/) ||
  1746.           (defined($ENV{'GATEWAY_INTERFACE'}) && $ENV{'GATEWAY_INTERFACE'} =~ /^CGI-Perl/))
  1747.         {
  1748.         $bNPH = $::TRUE;
  1749.         }
  1750.  
  1751.     #
  1752.     # Build a date for the expiry
  1753.     #
  1754.     my (@expires, $day, $month, $now, $later, $expiry, @now, $sNow);
  1755.     my (@days) = ('Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat');
  1756.     my (@months) = ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');
  1757.     
  1758.     $now = time;
  1759.     @now = gmtime($now);
  1760.     $day = $days[$now[6]];
  1761.     $month = $months[$now[4]];
  1762.     $sNow = sprintf("%s, %02d %s %04d %02d:%02d:%02d GMT", $day, $now[3],
  1763.                             $month, $now[5]+1900, $now[2], $now[1], $now[0]);
  1764.     $later = $now + 2 * 365 * 24 * 3600;            # Time in 2 years
  1765.     @expires = gmtime($later);                            # grab time components
  1766.     $day = $days[$expires[6]];
  1767.     $month = $months[$expires[4]];
  1768.     $expiry = sprintf("%s, %02d-%s-%04d %02d:%02d:%02d GMT", $day, $expires[3],
  1769.                             $month, $expires[5]+1900, $expires[2], $expires[1], $expires[0]);
  1770.     #
  1771.     # set the cookie if it needs to be set
  1772.     #
  1773.     my ($sCurrentCookie) = GetCookie();
  1774.     my $bCookie = ( (length $sCookie) > 0 &&        # if a cookie is to be saved
  1775.             $sCurrentCookie ne $sCookie);                # and it is a new value
  1776.     #
  1777.     # now print the header
  1778.     #
  1779.     if ($bNPH)
  1780.         {
  1781.         print "HTTP/1.0 200 OK\n";                        # the status
  1782.         }
  1783.     
  1784.     print "Content-type: $sType\n";
  1785.     print "Content-length: $nLength\n";
  1786.     print "Date: $sNow\n";                            # print the date to allow the browser to compensate between server and client differences
  1787.  
  1788.     if ($bNoCache)
  1789.         {
  1790.         print "Pragma: no-cache\n";
  1791.         }
  1792.  
  1793.     if ($bCookie)                                            # if we are to save the cookie
  1794.         {
  1795.         print "Set-Cookie: ACTINIC_CART=" .            # set the cookie
  1796.            $sCookie . "; EXPIRES=" .
  1797.             $expiry . "; PATH=/;\n";
  1798.         }
  1799.     
  1800.     if ($sContactDetailsCookie)                        # if we are to save the contact details cookie
  1801.         {
  1802.         print "Set-Cookie: " . $sContactDetailsCookie . # set the cookie
  1803.            "; EXPIRES=" . $expiry . "; PATH=/;\n";
  1804.         }
  1805.  
  1806.     if ($::ACT_ADB)                                # If there is an address book
  1807.         {
  1808.         print $::ACT_ADB->Header();            # Ouput address book cookies
  1809.         }
  1810.  
  1811.     my $sDigest = $ACTINIC::B2B->Get('UserIDCookie');                                        # If B2B user logged in - save the digest
  1812.     if ( $sDigest )
  1813.         {
  1814.         if ( $sDigest eq "." )
  1815.             {
  1816.             $sDigest = "";
  1817.             }
  1818.         print "Set-Cookie: ACTINIC_ACCOUNT=" . $sDigest .         # set the cookie - this session only
  1819.            "; PATH=/;\n";
  1820.         }
  1821.     else
  1822.         {
  1823.         if ( $ACTINIC::B2B->Get('ClearIDCookie') )
  1824.             {
  1825.             print "Set-Cookie: ACTINIC_ACCOUNT=; PATH=/;\n";         # Clear ID cookie
  1826.             }
  1827.         if ( $ACTINIC::B2B->Get('ClearUserCookie') )
  1828.             {
  1829.             print "Set-Cookie: ACTINIC_USERNAME=; PATH=/;\n";         # Clear username  cookie
  1830.             }
  1831.         }
  1832.     if ($ACTINIC::B2B->Get('BaseFileCookie'))                                            # If B2B user logged in - save the base file address
  1833.         {
  1834.         print "Set-Cookie: ACTINIC_BASEFILE=" . $ACTINIC::B2B->Get('BaseFileCookie') .    # set the cookie - this session only
  1835.            "; PATH=/;\n";
  1836.         }
  1837.     if ($ACTINIC::B2B->Get('UserNameCookie'))                                            # If B2B user logged in - save user name
  1838.         {
  1839.         print "Set-Cookie: ACTINIC_USERNAME=" . $ACTINIC::B2B->Get('UserNameCookie') .    # set the cookie - this session only
  1840.            "; PATH=/;\n";
  1841.         }
  1842.     if ($ACTINIC::B2B->Get('ProductFileCookie'))                                        # If B2B user logged in - ssve PRODUCTPAGE
  1843.         {
  1844.         print "Set-Cookie: ACTINIC_PRODUCTPAGE=" . $ACTINIC::B2B->Get('ProductFileCookie') .    # set the cookie - this session only
  1845.            "; PATH=/;\n";
  1846.         }
  1847.     
  1848.  
  1849.     print "\n";
  1850.     }
  1851.  
  1852. #######################################################
  1853. #
  1854. # PrintPage - print the HTML page
  1855. #
  1856. #    Params:     0 - HTML to print
  1857. #                1 - cookie if any (or undef)
  1858. #                2 - no-cache flag - if $::TRUE,
  1859. #                    include no-cache flag.
  1860. #                    Default - $::TRUE
  1861. #                3 - contact details cookie (optional)
  1862. #
  1863. #######################################################
  1864.  
  1865. sub PrintPage
  1866.     {
  1867. #? ACTINIC::ASSERT($#_ >= 1, "Invalid argument count in PrintPage ($#_)", __LINE__, __FILE__);
  1868.    if ($::s_nErrorRecursionCounter > 10)
  1869.         {
  1870.         $ACTINIC::AssertIsActive = $::TRUE;
  1871. #?      ACTINIC::TRACE('Callstack:\n%s', CallStack());
  1872.         }
  1873.    $::s_nErrorRecursionCounter++;
  1874.  
  1875.     #
  1876.     # !!!!!! This is a function commonly used by many utilities.  Any changes to its interface will
  1877.     # !!!!!! need to be verified with the various utility scripts.
  1878.     #
  1879.     
  1880.     my ($nLength, $sHTML, $sCookie, $bNoCacheFlag, $sContactDetailsCookie);
  1881.     ($sHTML, $sCookie, $bNoCacheFlag, $sContactDetailsCookie) = @_;
  1882.     
  1883.    if (!$ACTINIC::AssertIsActive)                     # skip the XML parsing if we are reporting an assert as this can cause infinite looping if the problem is in the customer account code
  1884.         {
  1885.         $sHTML = ACTINIC::ParseXML($sHTML);            # the body
  1886.         }
  1887.     $nLength = length $sHTML;
  1888.     
  1889.     if (!defined $bNoCacheFlag)                        # default the no cache flag to on
  1890.         {
  1891.         $bNoCacheFlag = $::TRUE;
  1892.         }
  1893.     
  1894.     PrintHeader('text/html', $nLength, $sCookie, $bNoCacheFlag, $sContactDetailsCookie);
  1895.  
  1896.     binmode STDOUT;                                        # dump in binary mode since Netscape likes it
  1897.     
  1898.     print $sHTML;                            # the body
  1899.     }
  1900.  
  1901. #######################################################
  1902. #
  1903. # PrintText - print the text page
  1904. #
  1905. #    Params:     0 - text to print
  1906. #
  1907. #######################################################
  1908.  
  1909. sub PrintText
  1910.     {
  1911. #? ACTINIC::ASSERT($#_ == 0, "Invalid argument count in PrintText ($#_)", __LINE__, __FILE__);
  1912.  
  1913.     #
  1914.     # !!!!!! This is a function commonly used by many utilities.  Any changes to its interface will
  1915.     # !!!!!! need to be verified with the various utility scripts.
  1916.     #
  1917.     
  1918.     my $sText = $_[0];
  1919.     
  1920.     my $nLength = length $sText;
  1921.     
  1922.     PrintHeader('text/plain', $nLength, undef, $::FALSE);
  1923.  
  1924.     binmode STDOUT;                                        # dump in binary mode since Netscape likes it
  1925.  
  1926.     print $sText;                                            # the body
  1927.     }
  1928.  
  1929. #######################################################
  1930. #                                                                        
  1931. # ReportError - report the specified error to the
  1932. #    browser and error file
  1933. #
  1934. # Params:    0 - error message
  1935. #                1 - the file path
  1936. #
  1937. #######################################################
  1938.  
  1939. sub ReportError
  1940.     {
  1941. #? ACTINIC::ASSERT($#_ == 1, "Invalid argument count in ReportError ($#_)", __LINE__, __FILE__);
  1942.  
  1943.     #
  1944.     # !!!!!! This is a function commonly used by many utilities.  Any changes to its interface will
  1945.     # !!!!!! need to be verified with the various utility scripts.
  1946.     #
  1947.     
  1948.     my ($sMessage, $sPath);
  1949.     ($sMessage, $sPath) = @_;
  1950.     
  1951.     RecordErrors(@_);                                        # record the error to the error file
  1952.     
  1953.     TerminalError($_[0]);                                # display the error
  1954.     }
  1955.  
  1956. #######################################################
  1957. #                                                                        
  1958. # RecordErrors - Record the specified error to the
  1959. #    error file
  1960. #
  1961. # Params:    0 - error message
  1962. #                1 - file path
  1963. #
  1964. #######################################################
  1965.  
  1966. sub RecordErrors
  1967.     {
  1968. #? ACTINIC::ASSERT($#_ == 1, "Invalid argument count in RecordErrors ($#_)", __LINE__, __FILE__);
  1969.  
  1970.     #
  1971.     # !!!!!! This is a function commonly used by many utilities.  Any changes to its interface will
  1972.     # !!!!!! need to be verified with the various utility scripts.
  1973.     #
  1974.     
  1975.     my ($sMessage, $sPath);
  1976.     ($sMessage, $sPath) = @_;
  1977.     
  1978.     #########
  1979.     # Write the error to the file
  1980.     #########
  1981.     my ($sPad, $sFormat, $sFile);
  1982.     $sPad = " "x100;
  1983.     $sFile = $sPath."error.err";
  1984.     
  1985.     SecurePath($sFile);                                    # make sure only valid filename characters exist in $file to prevent hanky panky
  1986.     
  1987.     open(NQFILE, ">>".$sFile);                            # Open the error file
  1988.     
  1989.     print NQFILE ("Program = ");                        # Begin to write error file details
  1990.     print NQFILE (substr($::prog_name.$sPad,0,8)); # Write error file details
  1991.     
  1992.     print NQFILE (", Program version = ");            # Write error file details
  1993.     print NQFILE (substr($::prog_ver.$sPad,0,6)); # Write error file details
  1994.     
  1995.     print NQFILE (", HTTP Server = ");                # Write error file details
  1996.     print NQFILE (substr($::ENV{'SERVER_SOFTWARE'}.$sPad,0,30)); # Write error file details
  1997.     
  1998.     print NQFILE (", Return code = ");                # Write error file details
  1999.     print NQFILE (substr("999".$sPad,0,20));        # Write error file details
  2000.     
  2001.     print NQFILE (", Date and Time = ");            # Write error file details
  2002.     
  2003.     my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst);
  2004.     ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime(time);    # platform independent time
  2005.     $mon++;                                                    # make month 1 based
  2006.     $year += 1900;                                            # make year AD based
  2007.     $sFormat = sprintf("%2.2d/%2.2d/%4.4d %2.2d:%2.2d:%2.2d", $mday, $mon, $year, $hour, $min, $sec);
  2008.     print NQFILE ($sFormat);                            # Write error file details
  2009.     
  2010.     print NQFILE (", Internal Errors = ");            # Write error file details
  2011.     print NQFILE ($sMessage);                            # Write error file details
  2012.     
  2013.     print NQFILE "\n";
  2014.     close NQFILE;
  2015.     
  2016.     ChangeAccess("rw", $sFile);                        # make the file accessible
  2017.     }
  2018.  
  2019. #######################################################
  2020. #
  2021. # TerminalError - generate the error html
  2022. #
  2023. #    Params:     0 - the error
  2024. #
  2025. #######################################################
  2026.  
  2027. sub TerminalError
  2028.     {
  2029. # No assert here because the assert function calls this function - recursion loop
  2030.     #
  2031.     # !!!!!! This is a function commonly used by many utilities.  Any changes to its interface will
  2032.     # !!!!!! need to be verified with the various utility scripts.
  2033.     #
  2034.     
  2035.     my ($sError, $sHTML);
  2036.     ($sError) = @_;                                        # get the error message
  2037.     
  2038.     $sHTML  = "<HTML><TITLE>Actinic</TITLE><BODY>";
  2039.     if (defined $::g_pPromptList)
  2040.         {
  2041.         $sHTML .= "<H1>" . GetPhrase(-1, 24) . "</H1>";
  2042.         $sHTML .= "<HR>" . GetPhrase(-1, 25) . ": $sError<HR>";
  2043.         $sHTML .= GetPhrase(-1, 26);
  2044.         }
  2045.     else                                                        # if the localized text file has not been read - assume english
  2046.         {
  2047.         $sHTML .= "<H1>" . "A General Script Error Occurred" . "</H1>";
  2048.         $sHTML .= "<HR>" . "Error" . ": $sError<HR>";
  2049.         $sHTML .= "Press the Browser back button and try again or contact your ISP.";
  2050.         }
  2051.     $sHTML .= "</BODY></HTML>";
  2052.     
  2053.     $ACTINIC::AssertIsActive = $::TRUE;
  2054.     PrintPage($sHTML, undef, $::TRUE);
  2055.     
  2056.     exit;
  2057.     }
  2058.  
  2059. #######################################################
  2060. #                                                                        
  2061. # MakeLinksAbsolute - make all file references
  2062. #    absolute (to the web site dir)
  2063. #
  2064. # Params:    0 - current HTML
  2065. #                1 - referring site url
  2066. #                2 - content url
  2067. #
  2068. # Returns:    0 - status
  2069. #                1 - error message
  2070. #                2 - modified text
  2071. #
  2072. # 3/11/99 - modified to accept single quotes - R. Zybert
  2073. #
  2074. #######################################################
  2075.  
  2076. sub MakeLinksAbsolute
  2077.     {
  2078. #? ACTINIC::ASSERT($#_ == 2, "Invalid argument count in MakeLinksAbsolute ($#_)", __LINE__, __FILE__);
  2079.     
  2080.     #
  2081.     # !!!!!! This is a function commonly used by many utilities.  Any changes to its interface will
  2082.     # !!!!!! need to be verified with the various utility scripts.
  2083.     #
  2084.     my ($sHTML, $sWebSiteUrl, $sContentUrl, $Status, $Message, @Response);
  2085.     ($sHTML, $sWebSiteUrl, $sContentUrl) = @_;
  2086.  
  2087.     $sContentUrl =~ s#/[^/]*$#/#;
  2088.     
  2089.     #######
  2090.     # make the file references point to the correct directory
  2091.     # Absolute addresses (starting from /) are unchanged (rz)
  2092.     #######
  2093.     $sHTML =~ s/<IMG([^>]*?)SRC=(['"])?(?!http(s?):)([^'"\/][^"\s]+)(['"\s])/<IMG$1SRC=$2$sContentUrl$3$4$5/gi;    # '<emacs format> # replace image file references
  2094.     $sHTML =~ s/<BODY([^>]*?)BACKGROUND=(['"])?(?!http(s?):)([^'"\/][^'"\s]+)(['"\s])/<BODY$1BACKGROUND=$2$sContentUrl$3$4$5/gi;    # ' <quote helps emacs format> # replace background imagefile refs
  2095.     $sHTML =~ s/CODEBASE=(['"])?(?!http(s?):)([^'"\/][^"\s]+)(['"\s])/CODEBASE=$1$sContentUrl$2$3$4/gi;    # ' <quote helps emacs format> # replace codebase references
  2096.     $sHTML =~ s/\.src\s*=\s*(['"])(?!http(s?):)([^'"\/][^"'\s]+)(["'])/\.src = $1$sContentUrl$2$3$4/gi;    # ' <quote helps emacs format> # replace javascript images
  2097.       $sHTML =~ s/<A([^>]*?)HREF=(['"])?(?!http(s?):|mailto:|#|\/|javascript:)([^'"\s]+)(['"\s])/<A$1HREF=$2$sWebSiteUrl$3$4$5/gi;    # " <quote helps emacs format> # replace hyperlink references
  2098.      $sHTML =~ s/<FRAME([^>]*?)SRC=(['"])?(?!http(s?):|mailto:|#)([^'"\/][^'"\s]+)(["\s])/<FRAME$1SRC=$2$sWebSiteUrl$3$4$5/gi;    # " <quote helps emacs format> # replace hyperlink references
  2099. #     $sHTML =~ s/<FRAME([^>]*?)SRC=(['"])?([^'"][^'"]+)(["'])/<FRAME$1SRC=$2$sWebSiteUrl$2$3$4/gi;    # Simpler frame format
  2100.     $sHTML =~ s/<INPUT([^>]*?)SRC=(['"])?(?!http(s?):)([^'"\/][^'"\s]+)(["\s])/<INPUT$1SRC=$2$sContentUrl$3$4$5/gi;    # " <quote helps emacs format> # replace image file references
  2101.     return ($::SUCCESS, '', $sHTML);                    # do the replacement
  2102.     }
  2103. ##################################################################################
  2104. #                                                                                                            #
  2105. # HTML manipulation functions - end                                                                #
  2106. #                                                                                                            #
  2107. ##################################################################################
  2108.  
  2109. ##################################################################################
  2110. #                                                                                                            #
  2111. # Generic Utilities - begin                                                                        #
  2112. #                                                                                                            #
  2113. ##################################################################################
  2114.  
  2115. #######################################################
  2116. #
  2117. # GetScriptNameRegexp
  2118. #
  2119. # Returns:     0 - a regexp that will match any of the
  2120. #                    standard Catalog scriptnames
  2121. #
  2122. #######################################################
  2123.  
  2124. sub GetScriptNameRegexp
  2125.     {
  2126.     my (@ScriptPathParts) = split /(\\|\/)/, $::ENV{"SCRIPT_NAME"};
  2127.     my ($sScriptBase);
  2128.     $sScriptBase = substr($ScriptPathParts[$#ScriptPathParts], 2);
  2129.     return ("(ca|os|nq|ts|cp|ss|sh|bb|md)$sScriptBase");
  2130.     }
  2131.                                                                                               
  2132. ############################################################
  2133. #  IsStaticPage
  2134. #  Test URL to guess if it represents a static page
  2135. #  
  2136. #   Argument : URL
  2137. #   Result   : $::TRUE for static page
  2138. #                 $::FALSE if not (or don't know)
  2139. #
  2140. #  Ryszard Zybert  Jul 24 20:32:07 BST 2000
  2141. #
  2142. #  Copyright (c) Actinic Software Ltd (2000)
  2143. ############################################################
  2144. sub IsStaticPage
  2145.     {
  2146.     my ($sURL) = @_;
  2147.     my $sRegExp = GetScriptNameRegexp();
  2148.     if( $sURL =~ /(\.htm(l?)(\#[^\#]*)*)|(\/)$/i and $sURL !~ /$sRegExp/ )
  2149.         {
  2150.         return ($::TRUE);
  2151.         }
  2152.     return ($::FALSE);
  2153.     }
  2154. #######################################################
  2155. #
  2156. # Modulus - use this division function in place of
  2157. #    the % operator in cases where performance is not an
  2158. #    issue *or* when it is likely that the number is
  2159. #    greater than 2^31.  This is required because Perl
  2160. #    5.003 on FreeBSD crashes with a floating point exception
  2161. #    in those cases.
  2162. #
  2163. # Params:    0 - a
  2164. #                1 - b
  2165. #        where c = a % b
  2166. #
  2167. # Returns:     0 - c
  2168. #
  2169. #######################################################
  2170.  
  2171. sub Modulus
  2172.     {
  2173. #? ACTINIC::ASSERT($#_ == 1, "Wrong number of arguments in Modulus ($#_)", __LINE__, __FILE__);
  2174.     my ($nA, $nB) = @_;
  2175.     #
  2176.     # a % b = int(a - b * int(a/b) )
  2177.     #
  2178.     my $nC = $nA - $nB * int($nA / $nB);
  2179. #?    if ($^O ne 'freebsd')
  2180. #?        {
  2181. #?        my $nD = $nA % $nB;
  2182. #? ACTINIC::ASSERT($nD == $nC, "Modulus emulation error $nC != $nD", __LINE__, __FILE__);
  2183. #?        }
  2184.     return($nC);
  2185.     }
  2186.  
  2187. #######################################################
  2188. #
  2189. # ReadTheDir
  2190. #     Open a directory and read its contents - this
  2191. #     is a hack-around for a bug in PerlIS for NT.
  2192. #
  2193. # Params:     0 - the directory path to read
  2194. #
  2195. # Returns:     0 - status code
  2196. #                1 - error message if any
  2197. #                2+ - file list (or 0, 0)
  2198. #
  2199. #######################################################
  2200.  
  2201. sub ReadTheDir
  2202.     {
  2203. #? ACTINIC::ASSERT($#_ == 0, "Invalid argument count in ReadTheDir ($#_)", __LINE__, __FILE__);
  2204.     
  2205.     #
  2206.     # !!!!!! This is a function commonly used by many utilities.  Any changes to its interface will
  2207.     # !!!!!! need to be verified with the various utility scripts.
  2208.     #
  2209.     
  2210.     my ($sPath, @FileList);
  2211.     ($sPath) = @_;                                            # get the path
  2212.     
  2213.     SecurePath($sPath);                                    # make sure only valid filename characters exist in $file to prevent hanky panky
  2214.     if( opendir (NQDIR, "$sPath") )                    # open the directory to get a file listing
  2215.         {                                                        # if successful,
  2216.         @FileList = readdir (NQDIR);                    # read the directory
  2217.         closedir (NQDIR);                                    # close the directory
  2218.         return ($::SUCCESS, '', @FileList);            # return the directory contents
  2219.         }
  2220.     
  2221.     if ($^O ne "MSWin32")
  2222.         {
  2223.         return($::FAILURE, GetPhrase(-1, 31, $sPath, $!), 0, 0);
  2224.         }
  2225.     #
  2226.     # if we are here, the open failed.  This is probably NT with the PerliS 303 bug
  2227.     #    try to read the directory using dos commands
  2228.     #
  2229.     my ($sDosPath, $sCommand);
  2230.     $sDosPath = $sPath;                                    # get the path of the directory to read
  2231.     $sDosPath =~ s/\//\\/g;                                # convert the forward slashes to dos backslashes
  2232.     
  2233.     $sCommand = "dir /B \"$sDosPath\"";
  2234.     
  2235.     unless (open (PIPE, $sCommand . " |"))
  2236.         {
  2237.         return($::FAILURE, GetPhrase(-1, 32, $sPath, $!), 0, 0);
  2238.         }
  2239.     
  2240.     @FileList = <PIPE>;                                    # read the contents of the directory
  2241.     chomp @FileList;                                        # remove the trailing newlines
  2242.     close (PIPE);                                            # close the file
  2243.     
  2244.     if ($#FileList == 0 &&                                # if the command returned file not found
  2245.          $FileList[0] =~ m/File Not Found/i)
  2246.         {
  2247.         my ($sMessage);
  2248.         $sMessage = $FileList[0];
  2249.         return($::FAILURE, GetPhrase(-1, 32, $sPath, $sMessage), 0, 0);
  2250.         }
  2251.     
  2252.     return ($::SUCCESS, '', @FileList);                # return the directory contents
  2253.     }
  2254.  
  2255. #######################################################
  2256. #                                                                        
  2257. # IsCatalogFramed - Is Catalog running in framed mode
  2258. #
  2259. # Returns:    ($ReturnCode)
  2260. #                $::TRUE if running in a Frame
  2261. #                $::FALSE if not
  2262. #
  2263. #######################################################
  2264.  
  2265. sub IsCatalogFramed
  2266.     {
  2267.     #
  2268.     # use the existence of navigation page 
  2269.     #
  2270.     return(CheckFileExists("framenavbar.html", GetPath())); 
  2271.     }
  2272.  
  2273. #######################################################
  2274. #                                                                        
  2275. # CheckFileExists - returns whether the given file 
  2276. #                exists and is readable
  2277. #
  2278. # Params:    [0] - File name
  2279. #                [1] - Path
  2280. #
  2281. # Returns:    ($ReturnCode)
  2282. #                $::TRUE if file exists and is readable
  2283. #                $::FALSE if not 
  2284. #
  2285. #######################################################
  2286.  
  2287. sub CheckFileExists
  2288.     {
  2289. #? ACTINIC::ASSERT($#_ == 1, "Wrong number of arguments in CheckFileExists", __LINE__, __FILE__);
  2290.  
  2291.     my ($sFileName, $sPath);
  2292.     ($sFileName, $sPath) = @_;
  2293.     #
  2294.     # build the file name 
  2295.     #
  2296.     my $sFile = $sPath . $sFileName;
  2297.     return (-e $sFile && -r $sFile);                    # does the file exist and is readable
  2298.     }
  2299.  
  2300. #######################################################
  2301. #                                                                        
  2302. # GetCatalogBasePageName - gets the file name of the
  2303. #        enclosing frame
  2304. #
  2305. # Params:    [0] - Path
  2306. #
  2307. # Returns:    ($ReturnCode, $sError, $sPageName)
  2308. #                $::TRUE if file exists and is readable, $::FALSE if not 
  2309. #                $sError if present or ""
  2310. #                $sBasePageName - base page name
  2311. #
  2312. #######################################################
  2313.  
  2314. sub GetCatalogBasePageName
  2315.     {
  2316. #? ACTINIC::ASSERT($#_ == 0, "Wrong number of arguments in GetCatalogBasePageName", __LINE__, __FILE__);
  2317.  
  2318.     my ($sPath, $sBasePageName, $sNavFileName);
  2319.     ($sPath) = @_;
  2320.     #
  2321.     # build the file name 
  2322.     #
  2323.     my $sFile = "framenavbar.html";
  2324.     if(!CheckFileExists($sFile, $sPath))
  2325.         {
  2326.         return($::FALSE, "$sFile could not be found", "");
  2327.         }
  2328.     $sNavFileName = $sPath . $sFile;
  2329.     #
  2330.     # open the file
  2331.     #
  2332.     unless (open (NAVFILE, "<$sNavFileName"))
  2333.         {
  2334.         return ($::FALSE, ACTINIC::GetPhrase(-1, 21, $sNavFileName, $!), '');
  2335.         }
  2336.     #
  2337.     # find a HTML fragment with the base page name
  2338.     #
  2339.         {
  2340.         local $/ = undef;
  2341.         $_ = <NAVFILE>;                                    # read the entire file into $_
  2342.  
  2343.         ($sBasePageName) = /\&BPN=([a-zA-Z0-9_.]+)[^>]*?TARGET="_(top|parent)"/i;
  2344. #? ACTINIC::ASSERT((length $sBasePageName) > 0, "Base page name not found", __LINE__, __FILE__);
  2345.         }
  2346.     close(NAVFILE);
  2347.     return ($::SUCCESS, "", $sBasePageName);        # return our base page name
  2348.     }
  2349.  
  2350. ##################################################################################
  2351. #                                                                                                            #
  2352. # Generic Utilities - end                                                                        #
  2353. #                                                                                                            #
  2354. ##################################################################################
  2355.  
  2356. ##############################################################################################################
  2357. #                                                                        
  2358. # CGI Input Processing (should use CGI.pm but forbidden)- Begin
  2359. #
  2360. ##############################################################################################################
  2361.  
  2362. #######################################################
  2363. #                                                                        
  2364. # ReadAndParseInput - read the input and parse it
  2365. #
  2366. # Expects:    $::ENV to be defined
  2367. #
  2368. # Returns:    0 - status
  2369. #                1 - error message
  2370. #                2 - the input string
  2371. #                3 - spacer to keep output even
  2372. #                4+ - input hash table
  2373. #
  2374. #######################################################
  2375.  
  2376. sub ReadAndParseInput
  2377.     {
  2378.     my ($InputData, $nInputLength);
  2379.     
  2380.     #
  2381.     # !!!!!! This is a function commonly used by many utilities.  Any changes to its interface will
  2382.     # !!!!!! need to be verified with the various utility scripts.
  2383.     #
  2384.     
  2385.     if ( (length $::ENV{'QUERY_STRING'}) > 0)        # if there is query string data (GET)
  2386.         {
  2387.         $InputData = $::ENV{'QUERY_STRING'};        # read it
  2388.         $nInputLength = length $InputData;
  2389.         }
  2390.     else                                                        # otherwise, there must be a POST
  2391.         {
  2392.         my ($nStep, $InputBuffer);
  2393.         $nInputLength = 0;
  2394.         $nStep = 0;
  2395.         while ($nInputLength != $ENV{'CONTENT_LENGTH'})    # read until you have the entire chunk of data
  2396.             {
  2397.             #
  2398.             # read the input
  2399.             #
  2400.             binmode STDIN;
  2401.             $nStep = read(STDIN, $InputBuffer, $ENV{'CONTENT_LENGTH'});  # Set $::g_InputData equal to user input
  2402.             $nInputLength += $nStep;                    # keep track of the total data length
  2403.             $InputData .= $InputBuffer;                # append the latest chunk to the total data buffer
  2404.             if (0 == $nStep)                                # EOF
  2405.                 {
  2406.                 last;                                            # stop read
  2407.                 }
  2408.             }
  2409.             
  2410.         if ($nInputLength != $ENV{'CONTENT_LENGTH'})
  2411.             {
  2412.             return ($::FAILURE, "Bad input.  The data length actually read ($nInputLength) does not match the length specified " . $ENV{'CONTENT_LENGTH'} . "\n", '', '', 0, 0);
  2413.             }    
  2414.         }
  2415.     $InputData =~ s/&$//;                                # loose any bogus trailing &'s
  2416.     $InputData =~ s/=$/= /;                                # make sure trailing ='s have a value
  2417.     my ($OriginalInputData);
  2418.     $OriginalInputData = $InputData;                    # copy the input string for use later
  2419.     
  2420.     if ($nInputLength == 0)                                # error if there was no input
  2421.         {
  2422.         return ($::FAILURE, "The input is NULL", '', '', 0, 0);
  2423.         }
  2424.     #
  2425.     # parse and decode the input
  2426.     #
  2427.     my (@CheckData, %DecodedInput);
  2428.     @CheckData = split (/[&=]/, $InputData);        # check the input line
  2429.     if ($#CheckData % 2 != 1)
  2430.         {
  2431.         return ($::FAILURE, "Bad input string \"" . $InputData . "\".  Argument count " . $#CheckData . ".\n", '', '', 0, 0);
  2432.         }
  2433.     my %EncodedInput = split(/[&=]/, $InputData);    # parse the input hash
  2434.     my ($key, $value);
  2435.     while (($key, $value) = each %EncodedInput)
  2436.         {
  2437.         $key = DecodeText($key, $ACTINIC::FORM_URL_ENCODED);    # decode the hash entry
  2438.         $value = DecodeText($value, $ACTINIC::FORM_URL_ENCODED);
  2439.         if ($key !~ /BLOB/i &&                            # if the input is not an order blob
  2440.              ($key =~ /\0/ ||                                # check for poison NULLs
  2441.               $value =~ /\0/))
  2442.             {
  2443.             return ($::FAILURE, "Input contains invalid characters.", undef, undef, undef, undef);
  2444.             }
  2445.  
  2446.         $DecodedInput{$key} = $value;
  2447.         }
  2448.     #
  2449.     # Now process the path to the catalog directory.  In stand alone mode, the path is hard coded in the script.
  2450.     # In Actinic Host mode, the path is derived from the SHOPID and the shop data file.
  2451.     #
  2452.     my ($status, $sError) = ProcessPath($DecodedInput{SHOP}, \%DecodedInput);
  2453.     if ($status != $::SUCCESS)
  2454.         {
  2455.         return ($status, $sError);
  2456.         }
  2457.  
  2458.     return ($::SUCCESS, '', $OriginalInputData, '', %DecodedInput);
  2459.     }
  2460.  
  2461. #######################################################
  2462. #                                                                        
  2463. # ProcessPath - process the input to derive a path
  2464. #   to the catalog directory
  2465. #
  2466. # Params:    0 - shop ID if in Actinic Host Mode
  2467. #               or undef if stand alone
  2468. #
  2469. # Returns:    0 - status
  2470. #                1 - error message
  2471. #
  2472. #######################################################
  2473.  
  2474. sub ProcessPath
  2475.     {
  2476. #? ACTINIC::ASSERT($#_ >= 0, "Invalid argument count in ProcessPath ($#_)", __LINE__, __FILE__);
  2477.     my ($sShopID, $rhInput) = @_;
  2478.     my ($status, $sError);
  2479.     #
  2480.     # Now process the path to the catalog directory.  In stand alone mode, the path is hard coded in the script.
  2481.     # In Actinic Host mode, the path is derived from the SHOPID and the shop data file.
  2482.     #
  2483.     my $sInitialPath = 'NETQUOTEVAR:PATH';
  2484.     if (!NETQUOTEVAR:ACTINICHOSTMODE)                # stand alone mode
  2485.         {
  2486.         $ACTINIC::s_sPath = $sInitialPath;
  2487.         }
  2488.     else
  2489.         {
  2490.         #
  2491.         # Check if the shop ID has nothing in it
  2492.         #
  2493.         if ($sShopID eq '' && 
  2494.             ($$rhInput{ACTION} eq 'AUTHORIZE' || $$rhInput{ACTION} eq 'OCC_VALIDATE'))
  2495.             {
  2496.             if(defined $$rhInput{PATH} && $$rhInput{PATH} ne '')
  2497.                 {
  2498.                 $ACTINIC::s_sPath = $$rhInput{PATH};
  2499.                 return ($::SUCCESS, undef);
  2500.                 }
  2501.             }
  2502.         #
  2503.         # Load the module for access to the configuration files
  2504.         #
  2505.         eval 'require MallUtil;';
  2506.         if ($@)                                                # the interface module does not exist
  2507.             {
  2508.             return ($::FAILURE, 'An error occurred loading the MallUtil module.  ' . $@);
  2509.             }
  2510.         #
  2511.         # Retrieve the appropriate record
  2512.         #
  2513.         my $pShop;
  2514.         ($status, $sError) = MallUtil::GetShopRecordFromShopID($sShopID, \$pShop);
  2515.         if ($status != $::SUCCESS)
  2516.             {
  2517.             return ($status, $sError);
  2518.             }
  2519.         # 
  2520.         # Retrieve the specific path
  2521.         # 
  2522.         $ACTINIC::s_sPath = $pShop->{PATH};
  2523.         }
  2524.  
  2525.     return ($::SUCCESS, undef);
  2526.     }
  2527.  
  2528. #######################################################
  2529. #                                                                        
  2530. # ProcessReferencePageData - keep track of the
  2531. #    reference page data
  2532. #
  2533. # Params:    0+ - InputHash
  2534. #
  2535. # Returns:    0 - status
  2536. #                1 - error message
  2537. #                2+ - page list
  2538. #
  2539. #######################################################
  2540.  
  2541. sub ProcessReferencePageData
  2542.     {
  2543. #? ACTINIC::ASSERT($#_ > 0, "Invalid argument count in ProcessReferencePageData ($#_)", __LINE__, __FILE__);
  2544.     
  2545.     my (%InputHash);
  2546.     (%InputHash) = @_;
  2547.     
  2548.     my ($sPages, @PageList);
  2549.     $sPages = $InputHash{"REFPAGE"};                    # read the pagelist from the params
  2550.     if (defined $sPages)
  2551.         {
  2552.         @PageList = split (/\|\|\|/, $sPages);        # parse the list
  2553.         }
  2554.     else
  2555.         {
  2556.         @PageList = ();
  2557.         }
  2558.     
  2559. #    if ($#PageList != -1 &&                                # if there are any entries and
  2560.     if ($#PageList > 0 &&                                # if there are any entries (not just END) and
  2561.          $PageList[$#PageList] eq "END")                # this was a page bounce
  2562.         {
  2563.         pop @PageList;                                        # drop the terminating "END" and don't add the bounce page to the
  2564.         }                                                        # history list
  2565.     else
  2566.         {
  2567.         my ($sRefPage);
  2568.         $sRefPage = GetReferrer();
  2569.         ($sRefPage) = split (/\&REFPAGE/, $sRefPage); # drop any refpage information from the referring page - we track that
  2570.         
  2571.         my ($sTopTag);
  2572.         $sTopTag = '#top';                                # the top flag sometimes causes problems, so make sure it
  2573.         $sRefPage =~ s/$sTopTag//g;                    # is stripped
  2574.         #
  2575.         # correct the referring page if we are using frames to make this CGI call and the call came
  2576.         # from the navigation bar.
  2577.         #
  2578.         if ($InputHash{BPN} ne '')                        # this call was made from the navigation frame
  2579.             {
  2580.             my $nIndex;
  2581.             #
  2582.             # strip the filename from the static page URL
  2583.             #
  2584.             while ($sRefPage =~ /\//g)
  2585.                 {
  2586.                 $nIndex = pos $sRefPage;                # locate the last "/"
  2587.                 }
  2588.             $sRefPage = substr ($sRefPage, 0, $nIndex);    # snag the url
  2589.             #
  2590.             # cat on the base page filename
  2591.             #
  2592.             $sRefPage .= $InputHash{BPN};
  2593.             }
  2594.         
  2595.         push (@PageList, $sRefPage);                    # add the last page to the list
  2596.         }
  2597.     
  2598.     #####
  2599.     # make sure any CGI queries in the ref page list include their query_string
  2600.     #####
  2601.     my ($sScriptName) = GetScriptNameRegexp();
  2602.     if ($PageList[$#PageList] =~ /$sScriptName$/)# if the refpage indicates there is a script in the list that does
  2603.         {                                                        # not have its query string,
  2604.         $PageList[$#PageList] .= "?" . $InputHash{'PREVQUERY'};          # add the query string
  2605.         }
  2606.     
  2607.     return ($::SUCCESS, '', @PageList);
  2608.     }
  2609.  
  2610. #######################################################
  2611. #                                                                        
  2612. # GetWebSiteURL - get the web site URL from the pagelist
  2613. #
  2614. # Params:    0+ - PageList
  2615. #
  2616. # Returns:    0 - status
  2617. #                1 - error message
  2618. #                2 - the URL of the directory of the referring
  2619. #                    document.  Relative links refer to this
  2620. #                    directory, and CGI calls should return
  2621. #                    the customer to this directory.
  2622. #                3 - URL of content directory.
  2623. #                    3 is usually identical to 2, but in the
  2624. #                    case of SSL, 2 is insecure and 3 is secure.
  2625. #                    in the future, we could expand 3 to actually
  2626. #                    refer to a different server.
  2627. #
  2628. #######################################################
  2629.  
  2630. sub GetWebSiteURL
  2631.     {
  2632. #? ACTINIC::ASSERT($#_ >= 0, "Invalid argument count in GetWebSiteUrl ($#_)", __LINE__, __FILE__);
  2633.     
  2634.     my (@PageList);
  2635.     (@PageList) = @_;
  2636.     
  2637.     if ($#PageList == -1)
  2638.         {
  2639.         my ($sDigest,$sBaseFile) = ACTINIC::CaccGetCookies();        # See if the user logged in
  2640.         if( !$sBaseFile )
  2641.             {
  2642.             return ($::FAILURE, "Unable to retrieve web site URL from NULL page list", '', 0);
  2643.             }
  2644.         else
  2645.             {
  2646.             $PageList[0] = $sBaseFile;
  2647.             }
  2648.         }
  2649.     
  2650.     #######
  2651.     # retrieve the web site url
  2652.     #######
  2653.     my ($nIndex, $sTemp, $sReferenceUrl);
  2654.     $sTemp = $PageList[0];                                # get the primary reference page
  2655.     while ($sTemp =~ /\//g)
  2656.         {
  2657.         $nIndex = pos $sTemp;                            # locate the last "/"
  2658.         }
  2659.     $sReferenceUrl = substr ($sTemp, 0, $nIndex);    # snag the url
  2660.     
  2661.     my $sContentUrl = $sReferenceUrl;
  2662.     
  2663.     if ($sContentUrl &&                                    # if the web site url has been defined and
  2664.         $$::g_pSetupBlob{USE_SSL})                        # we are using SSL security
  2665.         {
  2666.         $sContentUrl =~ s/http:\/\//https:\/\//i;    # make the images, etc. use secure transfer
  2667.         }
  2668.          
  2669.     return ($::SUCCESS, '', $sReferenceUrl, $sContentUrl);
  2670.     }
  2671.  
  2672. #######################################################
  2673. #                                                                        
  2674. # PrepareRefPageData - prepare the ref page data for
  2675. #    insertion into HTML
  2676. #
  2677. # Params:    0 - original input data
  2678. #                1 - pointer to the page list
  2679. #                2 - encode flag - If $::TRUE, encode the
  2680. #                        components of the refpage string
  2681. #                        before returning it
  2682. #
  2683. # Returns:    0 - status
  2684. #                1 - error message
  2685. #                2 - previous query string
  2686. #                3 - refpage string
  2687. #
  2688. #######################################################
  2689.  
  2690. sub PrepareRefPageData
  2691.     {
  2692. #? ASSERT($#_ == 2, "Incorrect parameter count in PrepareRefPageData", __LINE__, __FILE__);
  2693.  
  2694.     my ($sPrevQuery, $pPageList, $bEncode) = @_;
  2695.     ($sPrevQuery) = split (/\&REFPAGE/, $sPrevQuery); # drop any refpage information from the previous query - tracked sep
  2696.     #
  2697.     # encode the ref page list
  2698.     #
  2699.     my $sHistoryElement;
  2700.     my $sRefPageList;
  2701.     if ($bEncode)
  2702.         {
  2703.         foreach $sHistoryElement (@$pPageList)
  2704.             {
  2705.             my @Response = EncodeText($sHistoryElement, $::FALSE);
  2706.             $sRefPageList .= $Response[1] . '|||';
  2707.             }
  2708.         }
  2709.     else
  2710.         {
  2711.         $sRefPageList = join('|||', @$pPageList);
  2712.         $sRefPageList .= '|||';
  2713.         }
  2714.     return ($::SUCCESS, '', $sPrevQuery, $sRefPageList);
  2715.     }
  2716.  
  2717. ##############################################################################################################
  2718. #                                                                        
  2719. # CGI Input Processing (should use CGI.pm but forbidden)- End
  2720. #
  2721. ##############################################################################################################
  2722.  
  2723. ##############################################################################################################
  2724. #                                                                        
  2725. # File Read Calls - Begin
  2726. #
  2727. ##############################################################################################################
  2728.  
  2729. #######################################################
  2730. #                                                                        
  2731. # GetSectionBlobName - make the blob name from the ID
  2732. #
  2733. # Input:    0 - section ID
  2734. #
  2735. # Returns:    0 - return code ($::SUCCESS or $::FAILURE)
  2736. #           1 - error message (if any)
  2737. #                2 - blob name
  2738. #
  2739. #######################################################
  2740.  
  2741. sub GetSectionBlobName
  2742.     {
  2743. #? ACTINIC::ASSERT($#_ == 0, "Invalid argument count in GetSectionBlobName ($#_)", __LINE__, __FILE__);
  2744.     #
  2745.     # Validate the input ID - make sure it contains only digits
  2746.     #
  2747.     if ($_[0] !~ /^(\d+)$/)                                # if the section ID does not contain only digits
  2748.         {
  2749.         return ($::FAILURE, GetPhrase(-1, 306));        # bad input
  2750.         }
  2751.     my $nID = $1;                                            # retrieve the ID
  2752.     
  2753.     return ($::SUCCESS, undef, sprintf('A000%d.cat', $nID));    # format and return the filename
  2754.     }
  2755.  
  2756. #######################################################
  2757. #                                                                        
  2758. # GetProduct - locate a product object given its
  2759. #    product reference.  if the queried product has
  2760. #    been removed from the catalog, GetProduct will
  2761. #    return NOTFOUND.
  2762. #
  2763. # Params:    0 - the product reference
  2764. #                1 - the section blob filename
  2765. #                2 - file path
  2766. #
  2767. # Returns:    0 - status (SUCCESS, FAILURE, NOTFOUND)
  2768. #                1 - error message
  2769. #                2 - a reference to the product
  2770. #
  2771. #######################################################
  2772.  
  2773. sub GetProduct
  2774.     {
  2775. #? ACTINIC::ASSERT($#_ == 2, "Invalid argument count in GetProduct ($#_)", __LINE__, __FILE__);
  2776.     
  2777.     my ($ProductRef, $sSectionBlobFilename, $sPath);
  2778.     ($ProductRef, $sSectionBlobFilename, $sPath) = @_;
  2779.     if (length $ProductRef == 0)
  2780.         {
  2781.         return ($::FAILURE, GetPhrase(-1, 37), 0, 0);
  2782.         }
  2783.     #
  2784.     # see if the section is already in memory
  2785.     #
  2786.     my ($bInMemory);
  2787.     $bInMemory = defined $::g_pSectionList{$sSectionBlobFilename};
  2788.  
  2789.     #
  2790.     # If the item is not in memory, read the section blob
  2791.     #
  2792.     my (@Response, $Status, $Message);
  2793.     if (!$bInMemory)
  2794.         {
  2795.         @Response = ReadSectionFile($sPath.$sSectionBlobFilename);
  2796.         ($Status, $Message) = @Response;
  2797.         if ($Status != $::SUCCESS)
  2798.             {
  2799.             return ($::NOTFOUND, GetPhrase(-1, 173, $ProductRef), \%::g_DeletedProduct);
  2800.             }
  2801.         my $nVersion = 10;
  2802.         if (${$::g_pSectionList{$sSectionBlobFilename}}{VERSION} != $nVersion)        # not the correct blob version number
  2803.             {
  2804.             return ($::FAILURE, "Section blob version is " . ${$::g_pSectionList{$sSectionBlobFilename}}{VERSION} .
  2805.               ", but only version $nVersion is supported.  File: $sSectionBlobFilename", 0, 0);
  2806.             }    
  2807.         }
  2808.     #
  2809.     # see if the product was found in the file.  If not, the supplier must have removed the item from the
  2810.     # catalog after we added the item to the cart.
  2811.     #
  2812.  
  2813.     if (!defined ${$::g_pSectionList{$sSectionBlobFilename}}{$ProductRef})
  2814.         {
  2815.         return ($::NOTFOUND, GetPhrase(-1, 173, $ProductRef), \%::g_DeletedProduct);
  2816.         }
  2817.         
  2818.     return ($::SUCCESS, '', ${$::g_pSectionList{$sSectionBlobFilename}}{$ProductRef});
  2819.     }
  2820.  
  2821. #######################################################
  2822. #                                                                        
  2823. # GetProductReferenceFromVariant - translate the
  2824. #    specified product variant code into a product
  2825. #    reference.
  2826. #
  2827. # Params:    0 - the variant code
  2828. #                1 - the section blob filename
  2829. #                2 - file path
  2830. #
  2831. # Returns:    0 - status (SUCCESS, FAILURE, NOTFOUND)
  2832. #                1 - error message
  2833. #                2 - the product reference
  2834. #
  2835. #######################################################
  2836.  
  2837. sub GetProductReferenceFromVariant
  2838.     {
  2839. #? ACTINIC::ASSERT($#_ == 2, "Invalid argument count in GetProductReferenceFromVariant ($#_)", __LINE__, __FILE__);
  2840.     my ($sInvalidProductReference) = "'";
  2841.     my ($sVariantCode, $sSectionBlobFilename, $sPath);
  2842.     ($sVariantCode, $sSectionBlobFilename, $sPath) = @_;
  2843. #? ACTINIC::ASSERT(length $sVariantCode > 0, "Invalid product variant code (empty).", __LINE__, __FILE__);
  2844.     #
  2845.     # see if the section is already in memory
  2846.     #
  2847.     my ($bInMemory);
  2848.     $bInMemory = defined $::g_pVariantList{$sSectionBlobFilename};
  2849.     #
  2850.     # If the item is not in memory, read the section blob
  2851.     #
  2852.     my (@Response, $Status, $Message);
  2853.     if (!$bInMemory)
  2854.         {
  2855.         @Response = ReadSectionFile($sPath.$sSectionBlobFilename);
  2856.         ($Status, $Message) = @Response;
  2857.         if ($Status != $::SUCCESS)
  2858.             {
  2859.             return (@Response);
  2860.             }
  2861.         my $nVersion = 0;
  2862.         if (${$::g_pVariantList{$sSectionBlobFilename}}{VERSION} != $nVersion)    # not the correct blob version number
  2863.             {
  2864.             return ($::FAILURE, "Variant blob version is " . ${$::g_pVariantList{$sSectionBlobFilename}}{VERSION} .
  2865.                 ", but only version $nVersion is supported.  File: $sSectionBlobFilename", 0, 0);
  2866.             }
  2867.         }
  2868.     #
  2869.     # see if the product was found in the file.  If not, the supplier must have removed the item from the
  2870.     # catalog after we added the item to the cart.
  2871.     #
  2872.     if (!defined ${$::g_pVariantList{$sSectionBlobFilename}}{$sVariantCode})
  2873.         {
  2874.         return ($::FAILURE, GetPhrase(-1, 190, $sVariantCode), $sInvalidProductReference);
  2875.         }
  2876.         
  2877.     return ($::SUCCESS, undef, ${$::g_pVariantList{$sSectionBlobFilename}}{$sVariantCode});
  2878.     }
  2879.  
  2880. #######################################################
  2881. #                                                                        
  2882. # ReadSetupFile - read the setup blob file
  2883. #
  2884. # Params:    0 - path
  2885. #
  2886. # Returns:    0 - status
  2887. #                1 - error message
  2888. #
  2889. # Affects:    $::g_pSetupBlob - points to the global
  2890. #                    setup hash
  2891. #
  2892. #######################################################
  2893.  
  2894. sub ReadSetupFile
  2895.     {
  2896. #? ACTINIC::ASSERT($#_ == 0, "Invalid argument count in ReadSetupFile ($#_)", __LINE__, __FILE__);
  2897.     
  2898.     my @Response = ReadConfigurationFile($_[0]."nqset00.fil",'$g_pSetupBlob');    # load the catalog
  2899.     if ($Response[0] != $::SUCCESS)
  2900.         {
  2901.         return (@Response);
  2902.         }
  2903.         
  2904.     my $nSetupVersion = 23;
  2905.     if ($$::g_pSetupBlob{VERSION} != $nSetupVersion) # not the correct blob version number
  2906.         {
  2907.         return ($::FAILURE, "Setup blob version is " . $$::g_pSetupBlob{VERSION} .
  2908.             ", but only version $nSetupVersion is supported.", 0, 0);
  2909.         }
  2910.     my $nMinorVersion = 1;
  2911.     if ($$::g_pSetupBlob{MINOR_VERSION} < $nMinorVersion) # not the correct blob version number
  2912.         {
  2913.         return ($::FAILURE, "Setup blob minor version number is " . $$::g_pSetupBlob{MINOR_VERSION} .
  2914.             ", but minor version $nMinorVersion is required.", 0, 0);
  2915.         }
  2916. #? if ($$::g_pSetupBlob{MINOR_VERSION} > $nMinorVersion)
  2917. #?        {
  2918. #?        TRACE('Setup blob minor version number does not match the script minor version number.');
  2919. #?        TRACE("\tThe setup blob minor version number is " . '%d.', $$::g_pSetupBlob{MINOR_VERSION});
  2920. #?        TRACE("\tThe script expects minor version number " . '%d.', $nMinorVersion);
  2921. #?        }
  2922.     
  2923.     $::g_sRequiredColor    = $$::g_pSetupBlob{REQUIRED_COLOR}; # store the global required field color
  2924.  
  2925.     if ($::g_sContentUrl &&                                # if the web site url has been defined and
  2926.         $$::g_pSetupBlob{USE_SSL})                        # we are using SSL security
  2927.         {
  2928.         $::g_sContentUrl =~ s/http:\/\//https:\/\//i;    # make the images, etc. use secure transfer
  2929.         }
  2930.  
  2931.     $::g_sAccountScript = $$::g_pSetupBlob{CGI_URL};                # Full HTTP path to account script
  2932.     $::g_sAccountScript .= sprintf("bb%6.6d%s",$$::g_pSetupBlob{CGI_ID},$$::g_pSetupBlob{CGI_EXT});
  2933.     if( $$::g_pSetupBlob{USE_SSL} )
  2934.         {
  2935.         $::g_sAccountScript =~ s/http:\/\//https:\/\//i;    # make the script use SSL
  2936.         }
  2937.  
  2938.     # PRESNET
  2939.     # Presnet: set flags by uncommenting these changes
  2940.     #
  2941. #    $$::g_pSetupBlob{'EMAIL_ORDER'}    = $::TRUE;
  2942. #    $$::g_pSetupBlob{'REVERSE_ADDRESS_CHECK'}    = $::TRUE;
  2943. #    $$::g_pSetupBlob{'SUPPRESS_CART_WITH_CONFIRM'}    = $::TRUE;
  2944. #    $$::g_pSetupBlob{'DISPLAY_CART_AFTER_CONFIRM'}    = $::TRUE;
  2945. #    $$::g_pSetupBlob{'PROCEED_CHECKOUT'} = 'pwc.gif';
  2946. #    $$::g_pSetupBlob{'CONTINUE_SHOP'} = 'cs.gif';
  2947. #    $$::g_pSetupBlob{'EDIT_CART'} = 'ec.gif';
  2948. #    $$::g_pSetupBlob{'CONFIRM_IMG'} = 'cnfm.gif';
  2949. #    $$::g_pSetupBlob{'CANCEL_IMG'} = 'can.gif';
  2950. #    $$::g_pSetupBlob{'REMOVE_IMG'} = 'rem.gif';
  2951. #    $$::g_pSetupBlob{'EDIT_IMG'} = 'edit.gif';
  2952.     # PRESNET
  2953.          
  2954.     return ($::SUCCESS, "", 0, 0);                    # we are done
  2955.     }
  2956.  
  2957. #######################################################
  2958. #                                                                        
  2959. # ReadCatalogFile - read the catalog blob file.
  2960. #
  2961. # Params:    0 - path
  2962. #
  2963. # Returns:    0 - status
  2964. #                1 - error message
  2965. #
  2966. # Affects:    $::g_pCatalogBlob - points to the global
  2967. #                    catalog hash
  2968. #
  2969. #######################################################
  2970.  
  2971. sub ReadCatalogFile
  2972.     {
  2973. #? ACTINIC::ASSERT($#_ == 0, "Invalid argument count in ReadCatalogFile ($#_)", __LINE__, __FILE__);
  2974.     
  2975.     my @Response = ReadConfigurationFile($_[0]."A000.cat",'$g_pCatalogBlob');    # load the catalog
  2976.     if ($Response[0] != $::SUCCESS)
  2977.         {
  2978.         return (@Response);
  2979.         }
  2980.         
  2981.     if ($$::g_pCatalogBlob{VERSION} != 2)            # not the correct blob version number
  2982.         {
  2983.         return ($::FAILURE, "Catalog blob version is " . $$::g_pCatalogBlob{VERSION} .
  2984.             ", but only version 2 is supported.", 0, 0);
  2985.         }
  2986.         
  2987.     return ($::SUCCESS, "", 0, 0);                    # we are done
  2988.     }
  2989.  
  2990. #######################################################
  2991. #                                                                        
  2992. # ReadLocationsFile - read the location blob file.
  2993. #
  2994. # Params:    0 - path
  2995. #
  2996. # Returns:    0 - status
  2997. #                1 - error message
  2998. #
  2999. # Affects:    $::g_pLocationList - points to the global
  3000. #                    location hash
  3001. #
  3002. #######################################################
  3003.  
  3004. sub ReadLocationsFile
  3005.     {
  3006. #? ACTINIC::ASSERT($#_ == 0, "Invalid argument count in ReadLocationsFile ($#_)", __LINE__, __FILE__);
  3007.     
  3008.     my @Response = ReadConfigurationFile($_[0]."locations.fil",'$g_pLocationList');    # load the catalog
  3009.     if ($Response[0] != $::SUCCESS)
  3010.         {
  3011.         return (@Response);
  3012.         }
  3013.     my $nVersion = 1;
  3014.     if ($$::g_pLocationList{VERSION} != $nVersion)    # not the correct blob version number
  3015.         {
  3016.         return ($::FAILURE, "Location blob version is " . $$::g_pLocationList{VERSION} .
  3017.             ", but only version $nVersion is supported.", 0, 0);
  3018.         }
  3019.         
  3020.     return ($::SUCCESS, "", 0, 0);                    # we are done
  3021.     }
  3022.  
  3023. #######################################################
  3024. #                                                                        
  3025. # ReadSearchSetupFile - read the search setup blob file
  3026. #
  3027. # Params:    0 - path
  3028. #
  3029. # Returns:    0 - status
  3030. #                1 - error message
  3031. #
  3032. # Affects:    $::g_pSearchSetup - points to the global
  3033. #                    search setup hash
  3034. #
  3035. #######################################################
  3036.  
  3037. sub ReadSearchSetupFile
  3038.     {
  3039. #? ACTINIC::ASSERT($#_ == 0, "Invalid argument count in ReadSearchSetupFile ($#_)", __LINE__, __FILE__);
  3040.     
  3041.     my @Response = ReadConfigurationFile($_[0]."search.fil",'$g_pSearchSetup');    # load the catalog
  3042.     if ($Response[0] != $::SUCCESS)
  3043.         {
  3044.         return (@Response);
  3045.         }
  3046.     my $nVersion = 1;
  3047.     if ($$::g_pSearchSetup{VERSION} != $nVersion) # not the correct blob version number
  3048.         {
  3049.         return ($::FAILURE, "Search setup blob version is " . $$::g_pSearchSetup{VERSION} .
  3050.             ", but only version $nVersion is supported.", 0, 0);
  3051.         }
  3052.         
  3053.     return ($::SUCCESS, "", 0, 0);                    # we are done
  3054.     }
  3055.  
  3056. #######################################################
  3057. #                                                                        
  3058. # ReadTaxSetupFile - read the tax blob file.
  3059. #
  3060. # Params:    0 - path
  3061. #
  3062. # Returns:    0 - status
  3063. #                1 - error message
  3064. #
  3065. # Affects:    $::g_pLocationList - points to the global
  3066. #                    location hash
  3067. #
  3068. #######################################################
  3069.  
  3070. sub ReadTaxSetupFile
  3071.     {
  3072. #? ACTINIC::ASSERT($#_ == 0, "Invalid argument count in ReadTaxSetupFile ($#_)", __LINE__, __FILE__);
  3073.     
  3074.     my @Response = ReadConfigurationFile($_[0]."taxsetup.fil",'$g_pTaxSetupBlob','$g_pTaxZoneMembersTable');    # load the file
  3075.     if ($Response[0] != $::SUCCESS)
  3076.         {
  3077.         return (@Response);
  3078.         }
  3079.     my $nVersion = 1;
  3080.     if ($$::g_pTaxSetupBlob{VERSION} != $nVersion)    # not the correct blob version number
  3081.         {
  3082.         return ($::FAILURE, "Tax setup blob version is " . $$::g_pTaxSetupBlob{VERSION} .
  3083.             ", but only version $nVersion is supported.", 0, 0);
  3084.         }
  3085.         
  3086.     return ($::SUCCESS, "", 0, 0);                    # we are done
  3087.     }
  3088.  
  3089. #######################################################
  3090. #                                                                        
  3091. # ReadSectionFile - read the specified section blob
  3092. #    file
  3093. #
  3094. # Params:    0 - blob filename
  3095. #
  3096. # Returns:    0 - status
  3097. #                1 - error message
  3098. #
  3099. # Affects:    $::g_pSectionList - points to the global
  3100. #                    section hash
  3101. #
  3102. #######################################################
  3103.  
  3104. sub ReadSectionFile
  3105.     {
  3106. #? ACTINIC::ASSERT($#_ == 0, "Invalid argument count in ReadSectionFile ($#_)", __LINE__, __FILE__);
  3107.     
  3108.     my @Response = ReadConfigurationFile(@_,'%g_pSectionList');        # load the configuration
  3109.     if ($Response[0] != $::SUCCESS)
  3110.         {
  3111.         $Response[0] = $::NOTFOUND;                    # translate the failure into a product not found error
  3112.         return (@Response);
  3113.         }
  3114.     
  3115.     return ($::SUCCESS, "", 0, 0);                    # we are done
  3116.     }
  3117.  
  3118.  
  3119. #######################################################
  3120. #                                                                        
  3121. # ReadPhaseFile - read phase list
  3122. #
  3123. # Params:    0 - path
  3124. #
  3125. # Returns:    0 - status
  3126. #                1 - error message
  3127. #
  3128. # Affects:    $::g_pPhaseList - points to the global
  3129. #                    phase hash
  3130. #
  3131. #######################################################
  3132.  
  3133. sub ReadPhaseFile
  3134.     {
  3135. #? ACTINIC::ASSERT($#_ == 0, "Invalid argument count in ReadPhaseFile ($#_)", __LINE__, __FILE__);
  3136.     
  3137.     my @Response = ReadConfigurationFile($_[0]."phase.fil",'$g_pPhaseList');    # load the catalog
  3138.     if ($Response[0] != $::SUCCESS)
  3139.         {
  3140.         return (@Response);
  3141.         }
  3142.         
  3143.     if ($$::g_pPhaseList{VERSION} != 0)                # not the correct blob version number
  3144.         {
  3145.         return ($::FAILURE, "Phase blob version is " . $$::g_pPhaseList{VERSION} .
  3146.             ", but only version 0 is supported.", 0, 0);
  3147.         }
  3148.         
  3149.     return ($::SUCCESS, "", 0, 0);                    # we are done
  3150.     }
  3151.  
  3152. #######################################################
  3153. #                                                                        
  3154. # ReadPromptFile - read the prompt blob
  3155. #
  3156. # Params:    0 - path
  3157. #
  3158. # Returns:    0 - status
  3159. #                1 - error message
  3160. #
  3161. # Affects:    $::g_pPromptList - points to the global
  3162. #                    prompt hash
  3163. #
  3164. #######################################################
  3165.  
  3166. sub ReadPromptFile
  3167.     {
  3168. #? ACTINIC::ASSERT($#_ == 0, "Invalid argument count in ReadPromptFile ($#_)", __LINE__, __FILE__);
  3169.     
  3170.     my @Response = ReadConfigurationFile($_[0]."prompt.fil",'$g_pPromptList');    # load the catalog
  3171.     if ($Response[0] != $::SUCCESS)
  3172.         {
  3173.         return (@Response);
  3174.         }
  3175.         
  3176.     if ($$::g_pPromptList{VERSION} != 0)                # not the correct blob version number
  3177.         {
  3178.         return ($::FAILURE, "Prompt blob version is " . $$::g_pPromptList{VERSION} .
  3179.             ", but only version 0 is supported.", 0, 0);
  3180.         }
  3181.     #
  3182.     # load some common values into globals
  3183.     #    
  3184.     $::g_sCancelButtonLabel = GetPhrase(-1, 505);
  3185.     $::g_sConfirmButtonLabel = GetPhrase(-1, 153);
  3186.     $::g_sAddToButtonLabel = GetPhrase(-1, 154);
  3187.     $::g_sEditButtonLabel = GetPhrase(-1, 155);
  3188.     $::g_sRemoveButtonLabel = GetPhrase(-1, 156);
  3189.     $::g_sSearchButtonLabel = GetPhrase(-1, 157);
  3190.     #
  3191.     # the substitute product for products that have been deleted
  3192.     #
  3193.     %::g_DeletedProduct =
  3194.         (
  3195.         'REFERENCE' => ' ',
  3196.         'NAME' => ACTINIC::GetPhrase(-1, 174),
  3197.         'PRICE' => 0,
  3198.         'MIN' => 1,
  3199.         'MAX' => 0,
  3200.         'TAX_TREATMENT' => $ActinicOrder::ZERO
  3201.         );
  3202.     #
  3203.     # build some index tables to speed generic searches later
  3204.     #
  3205.     my @keys = keys %{$::g_pPromptList};
  3206.     my $list = join(' ', @keys);
  3207.     my @scratch = ($list =~ m/([-0-9]+),(\d+) /g);
  3208.     while ($#scratch != -1)
  3209.         {
  3210.         my $nPhraseID = pop @scratch;                    # find the next phrase ID
  3211.         push (@{$::g_PhraseIndex{pop @scratch}}, $nPhraseID); # add it to the stack for this phase
  3212.         }
  3213.     return ($::SUCCESS, "", 0, 0);                    # we are done
  3214.     }
  3215.  
  3216. #######################################################
  3217. #                                                                        
  3218. # ReadConfigurationFile - read the specified blob
  3219. #    file
  3220. #
  3221. # Params:    0 - blob filename
  3222. #           1... optional - global variables to be shared with
  3223. #                the script
  3224. #                Format:  '$foo','$bar',... would share $::foo and $::bar
  3225. #                This triggers an attempt to load Safe.pm and eval the
  3226. #                script in a Safe compartment. If Safe.pm cannot be loaded
  3227. #                eval is used and these arguments are ignored.
  3228. #                (See EvalInSafe())
  3229. #
  3230. # Returns:    0 - status
  3231. #                1 - error message
  3232. #
  3233. # Affects:    the appropriate blob
  3234. #
  3235. #######################################################
  3236.  
  3237. sub ReadConfigurationFile
  3238.     {
  3239. #? ACTINIC::ASSERT($#_ >= 0, "Invalid argument count in ReadConfigurationFile ($#_)", __LINE__, __FILE__);
  3240.  
  3241.     my $sFilename = shift;
  3242.     my $pShared   = \@_;                    # Optional list of shared variables
  3243.     
  3244.     my @Response = ReadAndVerifyFile($sFilename);
  3245.     if ($Response[0] != $::SUCCESS)
  3246.         {
  3247.         return(@Response);
  3248.         }
  3249.     #
  3250.     # execute the script (parse the blob)
  3251.     #
  3252.  
  3253.     if( !$ACTINIC::USESAFE or $#$pShared < 0 )                    # No shared variables - use eval
  3254.         {
  3255.         if (eval($Response[2]) != $::SUCCESS)
  3256.             {
  3257.             return ($::FAILURE, "Error loading configuration file $sFilename. $@", 0, 0);
  3258.             }
  3259.         }
  3260.     else
  3261.         {
  3262.         @Response = EvalInSafe($Response[2],$ACTINIC::USESAFEONLY,$pShared);    # Try to use Safe.pm
  3263.         if( $Response[0] != $::SUCCESS)
  3264.             {
  3265.             return ($::FAILURE, "Error loading configuration file $sFilename. $Response[1]", 0, 0);
  3266.             }
  3267.         }
  3268.     
  3269.     return ($::SUCCESS, "", 0, 0);                    # we are done
  3270.     }
  3271.  
  3272. #######################################################
  3273. #                                                                        
  3274. # ReadAndVerifyFile - read the specified script and
  3275. #    verify its signature
  3276. #
  3277. # Params:    0 - filename
  3278. #
  3279. # Returns:    0 - status
  3280. #                1 - error message
  3281. #                2 - script 
  3282. #
  3283. #######################################################
  3284.  
  3285. sub ReadAndVerifyFile
  3286.     {
  3287. #? ACTINIC::ASSERT($#_ == 0, "Invalid argument count in ReadAndVerifyFile ($#_)", __LINE__, __FILE__);
  3288.     
  3289.     my ($sFilename);
  3290.     ($sFilename) = @_;                                    # set the blob filename
  3291.     
  3292.     unless (open (SCRIPTFILE, "<$sFilename"))        # open the file
  3293.         {
  3294.         return ($::FAILURE, "Error opening configuration file $sFilename. $!", 0, 0);
  3295.         }
  3296.         
  3297.     my $nCheckSum = <SCRIPTFILE>;                        # read the checksum
  3298.     chomp $nCheckSum;                                        # strip any trailing CRLF
  3299.     $nCheckSum =~ s/;$//;                                # strip the trailing ;
  3300.  
  3301.     my $sScript;
  3302.     {
  3303.     local $/;
  3304.     $sScript = <SCRIPTFILE>;                            # read the entire file
  3305.     }
  3306.     close (SCRIPTFILE);                                    # close the file
  3307.     #
  3308.     # calculate the script checksum
  3309.     #
  3310.     my $uTotal;
  3311.         {
  3312.         use integer;        
  3313.         $uTotal = unpack('%32C*', $sScript);
  3314.         }
  3315.     #
  3316.     # verify the script
  3317.     #
  3318.     if ($nCheckSum != $uTotal)
  3319.         {
  3320.         return ($::FAILURE, "$sFilename is corrupt.  The signature is invalid.", 0, 0);
  3321.         }
  3322.  
  3323.     $sScript =~ s/\r//g;                                    # remove the dos <CR>
  3324.  
  3325.     return ($::SUCCESS, "", $sScript, 0);
  3326.     }
  3327.  
  3328. ################################################################
  3329. #
  3330. # GetBuyer - retrieve the buyer given the digest
  3331. #
  3332. # Input:       0 - digest
  3333. #           1 - path
  3334. #
  3335. # Returns:    0 - status
  3336. #           1 - error message if any
  3337. #           2 - a reference to the buyer hash
  3338. #
  3339. ################################################################
  3340.  
  3341. sub GetBuyer
  3342.     {
  3343. #? ACTINIC::ASSERT($#_ == 1, 'Incorrect parameter count ACTINIC::GetBuyer(' . join(', ', @_) . ").", __LINE__, __FILE__);
  3344.     #
  3345.     # Since we typically only retrieve one buyer per execution, it is OK to open the file,
  3346.     # do the lookup and close the file.  It is easier to maintain this way.
  3347.     #
  3348.     my ($sDigest, $sPath) = @_;
  3349.     if ($sDigest eq $ACTINIC::BuyerDigest)
  3350.         {
  3351.         return ($::SUCCESS, undef, \%ACTINIC::Buyer);
  3352.         }
  3353.     undef %ACTINIC::Buyer;
  3354.     undef $ACTINIC::BuyerDigest;
  3355.     #
  3356.     # Open and prepare the index
  3357.     #
  3358.     my $rFile = \*BUYERINDEX;
  3359.     my $sFilename = $sPath . "oldbuyer.fil";
  3360.     my ($status, $sMessage) = InitIndex($sFilename, $rFile, 0);
  3361.     if ($status != $::SUCCESS)
  3362.         {
  3363.         return ($status, $sMessage);
  3364.         }
  3365.    eval 'require Digest::MD5';        # Try loading MD5, drop dead gracefully if it is not there
  3366.    if ($@) 
  3367.         {
  3368.         return ($::FAILURE, ACTINIC::GetPhrase(-1, 211, $@));
  3369.         }
  3370.     #
  3371.     # Find the buyer
  3372.     #
  3373.     my $sUserName = $ACTINIC::B2B->Get('UserName');
  3374.     my $sUserHash = Digest::MD5::md5_hex($sUserName . $sDigest);
  3375.     my $sValue;
  3376.     ($status, $sMessage, $sValue) = IndexSearch($sUserHash, 2, $rFile, $sFilename);
  3377.     if ($status != $::SUCCESS)
  3378.         {
  3379.         CleanupIndex($rFile);
  3380.         return ($status, $sMessage);
  3381.         }
  3382.     CleanupIndex($rFile);
  3383.     #
  3384.     # Parse the index value into a hash.  See CCustomerBuyerItem::operator CString for packing details.
  3385.     #
  3386.    $sValue =~ s/([^ ])$/$1 /;                            # if there is no trailing space add one
  3387.    $sValue .= 'a';                              # this is used to prevent the split from stripping trailing empty fields
  3388.     my @Details = split(/ /, $sValue);
  3389.    pop @Details;                                            # clear the trailing bogus "a"
  3390.     my @Labels = qw (ID AccountID Status InvoiceAddressRule InvoiceAddressID DeliveryAddressRule
  3391.                           DeliveryAddressID MaximumOrderValue EmailOnOrder LimitOrderValue HideRetailPrices
  3392.                           EmailAddress Name Salutation Title TelephoneNumber FaxNumber);
  3393. #? ACTINIC::ASSERT($#Details == $#Labels, 'Corrupt index ACTINIC::GetBuyer(' . "$#Details != $#Labels).", __LINE__, __FILE__);
  3394.     my $nIndex;
  3395.     #
  3396.     # Load the hash.  Note that Labels and Details are sorted in the same order
  3397.     #
  3398.     foreach ($nIndex = 0; $nIndex <= $#Details; $nIndex++)
  3399.         {
  3400.         $ACTINIC::Buyer{$Labels[$nIndex]} = DecodeText($Details[$nIndex], $ACTINIC::FORM_URL_ENCODED);
  3401.         }
  3402.  
  3403.     $ACTINIC::BuyerDigest = $sDigest;                # remember the digest for automated access later
  3404.  
  3405.     return ($::SUCCESS, undef, \%ACTINIC::Buyer);
  3406.     }
  3407.  
  3408. ################################################################
  3409. #
  3410. # GetCustomerAccount - retrieve the customer given the ID
  3411. #
  3412. # Input:       0 - ID
  3413. #           1 - path
  3414. #
  3415. # Returns:    0 - status
  3416. #           1 - error message if any
  3417. #           2 - a reference to the account hash
  3418. #
  3419. ################################################################
  3420.  
  3421. sub GetCustomerAccount
  3422.     {
  3423. #? ACTINIC::ASSERT($#_ == 1, 'Incorrect parameter count ACTINIC::GetCustomerAccount(' . join(', ', @_) . ").", __LINE__, __FILE__);
  3424.     #
  3425.     # Since we typically only retrieve one account per execution, it is OK to open the file,
  3426.     # do the lookup and close the file.  It is easier to maintain this way.
  3427.     #
  3428.     my ($nID, $sPath) = @_;
  3429.     if ($nID == $ACTINIC::AccountID)
  3430.         {
  3431.         return ($::SUCCESS, undef, \%ACTINIC::Account);
  3432.         }
  3433.     undef %ACTINIC::Account;
  3434.     undef $ACTINIC::AccountID;
  3435.     #
  3436.     # Open and prepare the index
  3437.     #
  3438.     my $rFile = \*ACCOUNTINDEX;
  3439.     my $sFilename = $sPath . "oldaccount.fil";
  3440.     my ($status, $sMessage) = InitIndex($sFilename, $rFile, 0);
  3441.     if ($status != $::SUCCESS)
  3442.         {
  3443.         return ($status, $sMessage);
  3444.         }
  3445.     #
  3446.     # Find the account
  3447.     #
  3448.     my $sValue;
  3449.     ($status, $sMessage, $sValue) = IndexSearch($nID, 2, $rFile, $sFilename);
  3450.     if ($status != $::SUCCESS)
  3451.         {
  3452.         CleanupIndex($rFile);
  3453.         return ($status, $sMessage);
  3454.         }
  3455.     CleanupIndex($rFile);
  3456.     #
  3457.     # Parse the index value into a hash.  See CCustomerItem::operator CString and CIndexValueCustomerAccount::operator CString for packing details.
  3458.     #
  3459.    $sValue =~ s/([^ ])$/$1 /;                            # if there is no trailing space add one
  3460.    $sValue .= 'a';                              # this is used to prevent the split from stripping trailing empty fields
  3461.     my @Details = split(/ /, $sValue);
  3462.    pop @Details;                                            # clear the trailing bogus "a"
  3463.     my @Labels = qw (EmailOnOrder InvoiceAddressRule Status InvoiceAddress PriceSchedule DefaultPaymentMethod
  3464.                           AccountName EmailAddress TelephoneNumber FaxNumber Name Salutation Title AddressList);
  3465. #? ACTINIC::ASSERT($#Details == $#Labels, 'Corrupt index ACTINIC::GetAccount(' . "$#Details != $#Labels).", __LINE__, __FILE__);
  3466.     my $nIndex;
  3467.     #
  3468.     # Load the hash.  Note that Labels and Details are sorted in the same order
  3469.     #
  3470.     foreach ($nIndex = 0; $nIndex <= $#Details; $nIndex++)
  3471.         {
  3472.         $ACTINIC::Account{$Labels[$nIndex]} = DecodeText($Details[$nIndex], $ACTINIC::FORM_URL_ENCODED);
  3473.         }
  3474.  
  3475.     return ($::SUCCESS, undef, \%ACTINIC::Account);
  3476.     }
  3477.  
  3478. ################################################################
  3479. #
  3480. # GetCustomerAddress - get the customer account address
  3481. #
  3482. # Input:       0 - account ID
  3483. #           1 - address ID
  3484. #           2 - path
  3485. #
  3486. # Returns:    0 - status
  3487. #           1 - error message if any
  3488. #           2 - reference address hash
  3489. #
  3490. ################################################################
  3491.  
  3492. sub GetCustomerAddress
  3493.     {
  3494. #? ACTINIC::ASSERT($#_ == 2, 'Incorrect parameter count ACTINIC::GetCustomerAddress(' . join(', ', @_) . ").", __LINE__, __FILE__);
  3495.     #
  3496.     # Since we occasionally retrieve multiple addresses per execution, we only open the file if it is not open
  3497.     # and leave it open until explicitly closed.
  3498.     #
  3499.     my ($nAccountID, $nAddressID, $sPath) = @_;
  3500.     my $sIdentifier = $nAccountID . ":" . $nAddressID;
  3501.     if (defined $ACTINIC::Addresses{$sIdentifier})
  3502.         {
  3503.         return ($::SUCCESS, undef, $ACTINIC::Addresses{$sIdentifier});
  3504.         }
  3505.     #
  3506.     # If the file is not open, open and prepare the index
  3507.     #
  3508.     my $sFilename = $sPath . "oldaddress.fil";
  3509.     if (!defined $ACTINIC::rAddressFileHandle)
  3510.         {
  3511.         $ACTINIC::rAddressFileHandle = \*ADDRESSINDEX;
  3512.         my ($status, $sMessage) = InitIndex($sFilename, $ACTINIC::rAddressFileHandle, 0);
  3513.         if ($status != $::SUCCESS)
  3514.             {
  3515.             return ($status, $sMessage);
  3516.             }
  3517.         }
  3518.     #
  3519.     # Find the address
  3520.     #
  3521.     my ($status, $sMessage, $sValue) = IndexSearch($sIdentifier, 2, $ACTINIC::rAddressFileHandle, $sFilename);
  3522.     if ($status != $::SUCCESS)
  3523.         {
  3524.         CleanupIndex($ACTINIC::rAddressFileHandle);
  3525.         undef $ACTINIC::rAddressFileHandle;
  3526.         return ($status, $sMessage);
  3527.         }
  3528.     #
  3529.     # Parse the index value into a hash.  See CCustomerAddressItem::operator CString for packing details.
  3530.     #
  3531.    $sValue =~ s/([^ ])$/$1 /;                            # if there is no trailing space add one
  3532.    $sValue .= 'a';                              # this is used to prevent the split from stripping trailing empty fields
  3533.     my @Details = split(/ /, $sValue);
  3534.    pop @Details;                                            # clear the trailing bogus "a"
  3535.     my @Labels = qw (ValidAsInvoiceAddress ValidAsDeliveryAddress ExemptTax1 ExemptTax2 CountryCode StateCode Name
  3536.                           Line1 Line2 Line3 Line4 PostCode Tax1ExemptData Tax2ExemptData);
  3537. #? ACTINIC::ASSERT($#Details == $#Labels, 'Corrupt index ACTINIC::GetCustomerAddress(' . "$#Details != $#Labels).", __LINE__, __FILE__);
  3538.     my $nIndex;
  3539.     #
  3540.     # Load the hash.  Note that Labels and Details are sorted in the same order
  3541.     #
  3542.     foreach ($nIndex = 0; $nIndex <= $#Details; $nIndex++)
  3543.         {
  3544.         $ACTINIC::Addresses{$sIdentifier}{$Labels[$nIndex]} = DecodeText($Details[$nIndex], $ACTINIC::FORM_URL_ENCODED);
  3545.         }
  3546.  
  3547.     return ($::SUCCESS, undef, $ACTINIC::Addresses{$sIdentifier});
  3548.     }
  3549.  
  3550. ################################################################
  3551. #
  3552. # CloseCustomerAddressIndex - cleanup up the file
  3553. #
  3554. ################################################################
  3555.  
  3556. sub CloseCustomerAddressIndex
  3557.     {
  3558.     if (defined $ACTINIC::rAddressFileHandle)
  3559.         {
  3560.         CleanupIndex($ACTINIC::rAddressFileHandle);
  3561.         undef $ACTINIC::rAddressFileHandle;
  3562.         }
  3563.     }
  3564.  
  3565. ################################################################
  3566. #
  3567. # InitIndex - initialize the specified index file tables
  3568. #
  3569. # Input:       0 - the path to the data file
  3570. #           1 - a reference to the desired file handle
  3571. #           2 - expected file version
  3572. #
  3573. # Returns:    0 - status
  3574. #           1 - error message if any
  3575. #
  3576. ################################################################
  3577.  
  3578. sub InitIndex
  3579.     {
  3580. #? ACTINIC::ASSERT($#_ == 2, 'Incorrect parameter count ACTINIC::InitIndex(' . join(', ', @_) . ").", __LINE__, __FILE__);
  3581.     my ($sPath, $rFileHandle, $nExpectedVersion) = @_;
  3582.     #
  3583.     # Open the index.  Retry a couple of times on failure just incase an update is in progress.
  3584.     #
  3585.     my ($status, $sError);
  3586.     my $nRetryCount = $ACTINIC::MAX_RETRY_COUNT;
  3587.     $status = $::SUCCESS;
  3588.     while ($nRetryCount--)
  3589.         {
  3590.         unless (open ($rFileHandle, "<$sPath"))
  3591.             {
  3592.             $sError = $!;
  3593.             sleep $ACTINIC::RETRY_SLEEP_DURATION;    # pause a moment
  3594.             $status = $::FAILURE;
  3595.             $sError = ACTINIC::GetPhrase(-1, 282, $sPath, $sError);
  3596.             next;
  3597.             }
  3598.         binmode $rFileHandle;
  3599.        #
  3600.        # Check the file version number
  3601.        #
  3602.         my $sBuffer;
  3603.         unless (read($rFileHandle, $sBuffer, 2) == 2) # read the blob version number (a short)
  3604.             {
  3605.             $sError = $!;
  3606.             close ($rFileHandle);
  3607.             return ($::FAILURE, ACTINIC::GetPhrase(-1, 283, $sPath, $sError));
  3608.             }
  3609.  
  3610.         my ($nVersion) = unpack("n", $sBuffer);    # convert to a number
  3611.         if ($nVersion != $nExpectedVersion)
  3612.             {
  3613.             close($rFileHandle);
  3614.             sleep $ACTINIC::RETRY_SLEEP_DURATION;    # pause a moment
  3615.             $status = $::FAILURE;
  3616.             $sError = ACTINIC::GetPhrase(-1, 284, $sPath, $nExpectedVersion, $nVersion);
  3617.             next;
  3618.             }
  3619.  
  3620.         last;
  3621.         }
  3622.  
  3623.     return($status, $sError);
  3624.     }
  3625.  
  3626. ################################################################
  3627. #
  3628. # CleanupIndex - do the cleanup work
  3629. #
  3630. # Input:       0 - reference to the index file handle
  3631. #
  3632. ################################################################
  3633.  
  3634. sub CleanupIndex
  3635.     {
  3636.     close ($_[0]);
  3637.     }
  3638.  
  3639. ###############################################################
  3640. #
  3641. # IndexSearch - search an index for the key.  The result of
  3642. #   this recursive function is the index value.  This function
  3643. #   assumes that each key has exactly one value.  It can
  3644. #   be used for product and account indices.  Search indices
  3645. #   where multiple results are possible should use another
  3646. #   form of this function.
  3647. #
  3648. # Input:       0 - search key (or remaining fragment on
  3649. #               recursive call)
  3650. #           1 - point to start in the file
  3651. #           2 - file handle
  3652. #           3 - file path (for identification in errors)
  3653. #
  3654. # Returns:  0 - status
  3655. #           1 - error message
  3656. #           2 - value
  3657. #
  3658. ###############################################################
  3659.  
  3660. sub IndexSearch
  3661.     {
  3662. #? ACTINIC::ASSERT($#_ == 3, 'Incorrect parameter count IndexSearch(' . join(', ', @_) . ").", __LINE__, __FILE__);
  3663.     my ($sKey, $nLocation, $rFile, $sFileName) = @_;
  3664.  
  3665.     my ($nDependencies, $nCount, $nRefs, $sRefs, $sBuff, $sFragment, $sValue);
  3666.     my ($nIndex, $sSeek, $nHere, $nLength, $sNext, $nRead);
  3667.     # 
  3668.    # At the start of the file, we have an (empty) value list
  3669.    # followed by a list of dependency records
  3670.     # 
  3671.     unless (seek($rFile, $nLocation, 0))            # Seek to node
  3672.         {
  3673.         return ($::FAILURE, ACTINIC::GetPhrase(-1, 285, $sFileName, $!));
  3674.         }
  3675.     # 
  3676.    # Read the value (if any).
  3677.     # 
  3678.     unless (read($rFile, $sBuff, 2) == 2)            # Read the count
  3679.         {
  3680.         return ($::FAILURE, ACTINIC::GetPhrase(-1, 285, $sFileName, $!));
  3681.         }
  3682.  
  3683.     ($nCount) = unpack("n", $sBuff);                    # Turn into an integer
  3684.     
  3685.     for ($nIndex = 0; $nIndex < $nCount; $nIndex++)
  3686.         {
  3687.         unless (read($rFile, $sBuff, 2) == 2)        # Get value length
  3688.             {
  3689.             return ($::FAILURE, ACTINIC::GetPhrase(-1, 285, $sFileName, $!));
  3690.             }
  3691.  
  3692.         ($nLength) = unpack("n", $sBuff);            # unpack the value length
  3693.  
  3694.         unless (read ($rFile, $sValue, $nLength) == $nLength) # read the value
  3695.             {
  3696.             return ($::FAILURE, ACTINIC::GetPhrase(-1, 285, $sFileName, $!));
  3697.             }
  3698.         
  3699.         unless (read($rFile, $sBuff, 1) == 1)        # read the reference count
  3700.             {
  3701.             return ($::FAILURE, ACTINIC::GetPhrase(-1, 285, $sFileName, $!));
  3702.             }
  3703.         ($nRefs) = unpack("C", $sBuff);                # Unpack it
  3704.  
  3705.         $sRefs = "";                                        # Kill left-over references
  3706.         if ($nRefs > 0)
  3707.             {
  3708.             unless (read($rFile, $sRefs, $nRefs) == $nRefs)    # Read and ignore the actual refs
  3709.                 {
  3710.                 return ($::FAILURE, ACTINIC::GetPhrase(-1, 285, $sFileName, $!));
  3711.                 }
  3712.             }
  3713.  
  3714.         if ($sKey eq "")                    # If this is an exact match
  3715.             {
  3716. #? ACTINIC::ASSERT(1 == $nCount, "Index match not unique.", __LINE__, __FILE__);
  3717.             return ($::SUCCESS, undef, $sValue);
  3718.             }
  3719.         }
  3720.     # 
  3721.    # Now search the dependencies
  3722.    #
  3723.     unless (read($rFile, $sBuff, 2) == 2)            # Read count
  3724.         {
  3725.         return ($::FAILURE, ACTINIC::GetPhrase(-1, 285, $sFileName, $!));
  3726.         }
  3727.     $nDependencies = unpack("n", $sBuff);            # Count of dependencies (network short)
  3728.     
  3729.     for ($nIndex = 0; $nIndex < $nDependencies; $nIndex++)
  3730.         {
  3731.         unless (read($rFile, $sBuff, 1) == 1)        # Read fragment length
  3732.             {
  3733.             return ($::FAILURE, ACTINIC::GetPhrase(-1, 285, $sFileName, $!));
  3734.             }
  3735.         $nLength = unpack("C", $sBuff);                # Unpack it
  3736.  
  3737.         unless (read($rFile, $sFragment, $nLength) == $nLength) # Read the string fragment
  3738.             {
  3739.             return ($::FAILURE, ACTINIC::GetPhrase(-1, 285, $sFileName, $!));
  3740.             }
  3741.         unless (read($rFile, $sSeek, 4) == 4)        # Read the link (convert later, if we need it)
  3742.             {
  3743.             return ($::FAILURE, ACTINIC::GetPhrase(-1, 285, $sFileName, $!));
  3744.             }
  3745.         #
  3746.         # We only care about the fragment length as far as
  3747.         # the length of the word we're looking for
  3748.         #
  3749.         $sFragment = substr($sFragment, 0, length($sKey)); # Reduce fragment to useful length
  3750.         #
  3751.         # If the fragment partially matches our word then we
  3752.         # continue down the tree. It only needs to match as much
  3753.         # of the word as we have - it's perfectly possible for
  3754.         # the fragment to be longer than the word
  3755.         #
  3756.         if ($sKey =~ m/^$sFragment/) # Does it match?
  3757.             {
  3758.             $sNext = $';                                    # Get part after match
  3759.             $nHere = tell($rFile);                        # Save where we are
  3760.  
  3761.             my ($status, $sError, $sValue) = IndexSearch($sNext, unpack("N", $sSeek), $rFile, $sFileName); # Look down tree
  3762.             if ($status == $::FAILURE ||                # if the lookup errored or
  3763.                  $status == $::SUCCESS)                    # if it was completed, 
  3764.                 {
  3765.                 return ($status, $sError, $sValue);    # return the state
  3766.                 }
  3767.             #
  3768.             # If we are here, $::NOTFOUND was returned, try the next one
  3769.             #
  3770.             unless (seek($rFile, $nHere, 0))            # Back to where we were
  3771.                 {
  3772.                 return ($::FAILURE, ACTINIC::GetPhrase(-1, 285, $sFileName, $!));
  3773.                 }
  3774.             }
  3775.  
  3776.         if ($sFragment gt $sKey)                        # If we've passed the point in the list
  3777.             {
  3778.             last;                                                # Don't look further
  3779.             } 
  3780.         }
  3781.  
  3782.     return ($::NOTFOUND, 'Item not found in index');
  3783.     }
  3784.  
  3785. #######################################################
  3786. #                                                                        
  3787. # GetPhrase  - Get the specified phrase and format it.
  3788. #
  3789. # Params:    0 - phase number
  3790. #                1 - prompt number
  3791. #                2+ - optional list of arguments supplied
  3792. #                    to complete string formatting
  3793. #
  3794. # Returns:    0 - prompt string
  3795. #
  3796. #######################################################
  3797.  
  3798. sub GetPhrase
  3799.     {
  3800. #? ACTINIC::ASSERT($#_ >= 1, "Invalid argument count in GetPhrase ($#_)", __LINE__, __FILE__);
  3801.  
  3802.     #
  3803.     # !!!!!! This is a function commonly used by many utilities.  Any changes to its interface will
  3804.     # !!!!!! need to be verified with the various utility scripts.
  3805.     #
  3806.     
  3807.     no strict 'refs';                                        # this class routine symbolic references
  3808.     my ($nPhase, $nPrompt, @args);
  3809.     if ($#_ < 1)                                            # incorrect number of arguments
  3810.         {
  3811.         $nPhase = -1;                                        # return parameters not set
  3812.         $nPrompt = 12;
  3813.         @args = ('GetPhrase');
  3814.         }
  3815.     else
  3816.         {
  3817.         ($nPhase, $nPrompt, @args) = @_;
  3818.         }
  3819.     
  3820.     my ($sPhrase);
  3821.     if (defined $::g_pPromptList)                        # if the phrase list is defined and
  3822.         {
  3823.         $sPhrase = $$::g_pPromptList{"$nPhase,$nPrompt"}{PROMPT};
  3824.         }
  3825.     elsif (defined $::g_InputHash{"PHRASE$nPhase,$nPrompt"}) # the phrases are in hidden parameters
  3826.         {
  3827.         $sPhrase = $::g_InputHash{"PHRASE$nPhase,$nPrompt"};
  3828.         }
  3829.     else
  3830.         {
  3831.         return ("Phrases not read yet ($nPhase,$nPrompt) {" . join(', ', @args) . "}.");            # report so
  3832.         }    
  3833.     #
  3834.     # process any substitution
  3835.     #
  3836.     if (defined $sPhrase &&                                # if the phrase was found and
  3837.          $#args > -1)                                        # there are values to substitute
  3838.         {
  3839.         $sPhrase = sprintf($sPhrase, @args);        # perform the substitution
  3840.         }
  3841.     
  3842.     if (defined $sPhrase)                                # if the phrase was defined
  3843.         {
  3844.         return ($sPhrase);                                 # return the phrase
  3845.         }
  3846.  
  3847.     return ("Phrase not found ($nPhase,$nPrompt) {" . join(', ', @args) . "}!!");
  3848.     }
  3849.  
  3850. #######################################################
  3851. #                                                                        
  3852. # GetRequireMessage - retrieve the "this field is required"
  3853. #    message for the specified phase and prompt
  3854. #
  3855. # Params:    0 - phase number
  3856. #                1 - prompt number
  3857. #
  3858. # Returns:    0 - message
  3859. #
  3860. #######################################################
  3861.  
  3862. sub GetRequiredMessage
  3863.     {
  3864. #? ACTINIC::ASSERT($#_ == 1, "Invalid argument count in GetRequireMessage ($#_)", __LINE__, __FILE__);
  3865.     return
  3866.             (
  3867.             GetPhrase(-1, 55, "\"<B><FONT COLOR=\"" . $::g_sRequiredColor .
  3868.             "\">" . GetPhrase($_[0], $_[1]) . "</FONT></B>\"") . "<BR>\n"
  3869.             );
  3870.     }
  3871.  
  3872. #######################################################
  3873. #                                                                        
  3874. # IsPromptRequired - is the specified prompt required.
  3875. #    For simplicity, all errors return $::FALSE.
  3876. #
  3877. # Params:    0 - phase number
  3878. #                1 - prompt number
  3879. #
  3880. # Returns:    0 - $::TRUE if required
  3881. #
  3882. #######################################################
  3883.  
  3884. sub IsPromptRequired
  3885.     {
  3886. #? ACTINIC::ASSERT($#_ == 1, "Invalid argument count in IsPromptRequired ($#_)", __LINE__, __FILE__);
  3887.  
  3888.     no strict 'refs';                                        # this class routine symbolic references
  3889.     if ($#_ != 1)                                            # incorrect number of arguments
  3890.         {
  3891.         return ($::FALSE);
  3892.         }
  3893.     
  3894.     my ($nPhase, $nPrompt) = @_;
  3895.     #
  3896.     # locate the prompt and return its status
  3897.     #
  3898.     return ($$::g_pPromptList{"$nPhase,$nPrompt"}{STATUS} == $::REQUIRED ? $::TRUE : $::FALSE); # return it's required status
  3899.     }
  3900.  
  3901. #######################################################
  3902. #                                                                        
  3903. # IsPromptHidden - is the specified prompt hidden.
  3904. #    For simplicity, all errors return $::FALSE.
  3905. #
  3906. # Params:    0 - phase number
  3907. #                1 - prompt number
  3908. #
  3909. # Returns:    0 - $::TRUE if hidden
  3910. #
  3911. #######################################################
  3912.  
  3913. sub IsPromptHidden
  3914.     {
  3915. #? ACTINIC::ASSERT($#_ == 1, "Invalid argument count in IsPromptHidden ($#_)", __LINE__, __FILE__);
  3916.     no strict 'refs';                                        # this class routine symbolic references
  3917.     if ($#_ != 1)                                            # incorrect number of arguments
  3918.         {
  3919.         return ($::FALSE);
  3920.         }
  3921.     
  3922.     my ($nPhase, $nPrompt) = @_;
  3923.     #
  3924.     # locate the prompt and return its status
  3925.     #
  3926.     return ($$::g_pPromptList{"$nPhase,$nPrompt"}{STATUS} == $::HIDDEN ? $::TRUE : $::FALSE); # return it's hidden status
  3927.     }
  3928.  
  3929. #######################################################
  3930. # ChangeAccess                                        
  3931. #     Change the access permissions using the various 
  3932. #     platform specific calls.                        
  3933. #                                                                        
  3934. # Params:    0 - the new mode of the file.  supported
  3935. #                    modes are '' - no permissions,
  3936. #                    "r" - read only, "rw" - read/write
  3937. #             1 - the file to modify                      
  3938. #
  3939. # Returns:    number of files changed
  3940. #
  3941. #######################################################
  3942.  
  3943. sub ChangeAccess
  3944.     {
  3945. # No assert here because ASSERT calls TRACE which calls ChangeAccess - recursion loop
  3946.     #
  3947.     # !!!!!! This is a function commonly used by many utilities.  Any changes to its interface will
  3948.     # !!!!!! need to be verified with the various utility scripts.
  3949.     #
  3950.     
  3951.     my ($mode, $file, $nCount);
  3952.     ($mode, $file) = @_;
  3953.  
  3954.     SecurePath($file);                                    # make sure only valid filename characters exist in $file to prevent hanky panky
  3955.     if ($mode eq '')                                        # no permissions
  3956.         {
  3957.         $nCount = chmod 0200, $file;                    # process chmod on unix
  3958.         }
  3959.     elsif ($mode eq "rw")
  3960.         {
  3961.         $nCount = chmod 0666, $file;                    # process chmod on unix
  3962.         }        
  3963.     elsif ($mode eq "r")
  3964.         {
  3965.         $nCount = chmod 0644, $file;                    # process chmod on unix
  3966.         }
  3967.     
  3968.     return ($nCount);
  3969.     }
  3970.  
  3971. #######################################################
  3972. #
  3973. # CleanFileName - Clean iffy characters from file name
  3974. #    only letters, digits, '.','_','-' allowed
  3975. #    each is changed into '_'
  3976. #
  3977. #    CAUTION: '/' is not allowed!
  3978. #
  3979. # Params:    file name
  3980. # Returns:    modified name
  3981. #
  3982. # (rz)
  3983. #######################################################
  3984.  
  3985. sub CleanFileName
  3986.     {
  3987.     my $nam = shift;
  3988.     $nam =~ tr/a-zA-Z0-9\.\_\-/_/c;
  3989.     return $nam;
  3990.     }
  3991.  
  3992. #######################################################
  3993. #
  3994. # SecurePath2 - Return an error if the specified path contains
  3995. #    any shell characters
  3996. #                                                                        
  3997. # Input:       0 - path
  3998. #
  3999. # Returns:  0 - error or undef
  4000. #
  4001. #######################################################
  4002.  
  4003. sub SecurePath2
  4004.     {
  4005.     my ($sPath) = $_[0];
  4006.     if ($^O eq 'MSWin32')                                # NT
  4007.         {
  4008.         if ($sPath =~ m|[!&<>\|*?()^;\${}\[\]\`\'\"~\n\r]| ||        # the secure path characters (allow backslashes)
  4009.              $sPath =~ m|\0|)
  4010.             {
  4011.             return("\"$sPath\" contains invalid characters.");
  4012.             }
  4013.         }
  4014.     else
  4015.         {
  4016.         if ($sPath =~ m|[!&<>\|*?()^;\${}\[\]\`\'\"\\~\n\r]| ||        # the secure path characters (no backslashes)
  4017.              $sPath =~ m|\0|)
  4018.             {
  4019.             return("\"$sPath\" contains invalid characters.");
  4020.             }
  4021.         }
  4022.     return (undef);
  4023.     }
  4024.  
  4025. #######################################################
  4026. #
  4027. # SecurePath - Error out if the specified path contains
  4028. #    any shell characters
  4029. #                                                                        
  4030. # Params:    0 - path
  4031. #
  4032. #######################################################
  4033.  
  4034. sub SecurePath
  4035.     {
  4036.     my $sError = SecurePath2(@_);
  4037.     if ($sError)
  4038.         {
  4039.         TerminalError($sError);
  4040.         }
  4041.     }
  4042.  
  4043. #######################################################
  4044. #
  4045. # CheckForShellCharacters - this is not as safe as
  4046. #  only tolerating specific characters, but for this
  4047. #  release, this is all we have time for.
  4048. #                                                                        
  4049. # Input:       0 - value to check
  4050. #
  4051. # Returns:  0 - error message if any, undef if OK
  4052. #
  4053. #######################################################
  4054.  
  4055. sub CheckForShellCharacters
  4056.     {
  4057.     my ($sValue) = $_[0];
  4058.     if ($sValue =~ m|[!&<>\|*?()^;\${}\[\]\`\'\"\\~\n\r]| ||        # the secure path characters (no backslashes)
  4059.          $sValue =~ m|\0|)
  4060.         {
  4061.         return ("\"$sValue\" contains invalid characters.");
  4062.         }
  4063.     return (undef);
  4064.     }
  4065.  
  4066. #######################################################
  4067. #
  4068. # GetPath - retrieve the path to the catalog directory
  4069. #                                                                        
  4070. # Returns:  0 - path
  4071. #
  4072. #######################################################
  4073.  
  4074. sub GetPath
  4075.     {
  4076.     return ($ACTINIC::s_sPath);
  4077.     }
  4078.  
  4079. #######################################################
  4080. #
  4081. # AuthenticateUser - verify the username and password
  4082. #  Exits on error.
  4083. #                                                                        
  4084. # Input:       0 - user
  4085. #                1 - password
  4086. #
  4087. # Returns:  0 - status
  4088. #           1 - message
  4089. #
  4090. #######################################################
  4091.  
  4092. sub AuthenticateUser
  4093.     {
  4094.     my ($sUsername, $sPassword) = @_;
  4095.     my ($sCorrectUsername, $sCorrectPassword) = ('NETQUOTEVAR:USERNAME', 'NETQUOTEVAR:PASSWORD');
  4096.     #
  4097.     # The username and password must be defined.
  4098.     #
  4099.     if (!$sUsername ||
  4100.          !$sPassword)
  4101.         {
  4102.         sleep $ACTINIC::DOS_SLEEP_DURATION;            # Discourage DOS attacks
  4103.         return ($::FAILURE, "Undefined Catalog username or password.  Check your Housekeeping | Security settings and try again.  If that fails, try refreshing the site.");
  4104.         }
  4105.     #
  4106.     # Verify the account
  4107.     #
  4108.     if (!NETQUOTEVAR:ACTINICHOSTMODE)                # stand alone mode
  4109.         {
  4110.         if ($sUsername ne $sCorrectUsername ||        # either the username or password does not match
  4111.              $sPassword ne $sCorrectPassword)
  4112.             {
  4113.             sleep $ACTINIC::DOS_SLEEP_DURATION;        # Discourage DOS attacks
  4114.             return ($::FAILURE, "Bad Catalog username or password.  Check your Housekeeping | Security settings and try again.  If that fails, try refreshing the site.");
  4115.             }
  4116.         }
  4117.     else                                                        # Actinic Host mode
  4118.         {
  4119.         #
  4120.         # Load the module for access to the configuration files
  4121.         #
  4122.         eval 'require MallUtil;';
  4123.         if ($@)                                                # the interface module does not exist
  4124.             {
  4125.             return ($::FAILURE, 'An error occurred loading the MallUtil module.  ' . $@);
  4126.             }
  4127.         #
  4128.         # Retrieve the appropriate record
  4129.         #
  4130.         my $pShop;
  4131.         my ($status, $sError) = MallUtil::GetShopRecordFromUsernameAndPassword($sUsername, $sPassword, \$pShop);
  4132.         if ($status == $::BADDATA)
  4133.             {
  4134.             sleep $ACTINIC::DOS_SLEEP_DURATION;        # Discourage DOS attacks
  4135.             return ($status, $sError);
  4136.             }
  4137.         elsif ($status != $::SUCCESS)
  4138.             {
  4139.             return ($status, $sError);
  4140.             }
  4141.         }
  4142.  
  4143.     return ($::SUCCESS, undef);
  4144.     }
  4145.  
  4146. #######################################################
  4147. #
  4148. # GetLastNonScript - return the last non-script page                                        
  4149. #     in a page list.                        
  4150. #                                                                        
  4151. # Params:    0 - pointer to page list
  4152. #
  4153. # Returns:    $sRefPage    - last non-script page or the 
  4154. #                                last page
  4155. #
  4156. #######################################################
  4157.  
  4158. sub GetLastNonScript
  4159.     {
  4160. #? ACTINIC::ASSERT($#_ == 0, "Invalid argument count in GetLastNonScript ($#_)", __LINE__, __FILE__);
  4161.     my ($sRefPage, $pPageList, $i);
  4162.     ($pPageList) = @_;
  4163.     
  4164.     $sRefPage = $$pPageList[-1];                        # make sure we return something!!
  4165.     #
  4166.     # build the pattern for our script name with '\w\w' in place of os, ca, al etc
  4167.     #
  4168.     my $sScriptURL = sprintf('%s(nph-)?\w\w%6.6d%s', $$::g_pSetupBlob{'CGI_URL'}, $$::g_pSetupBlob{'CGI_ID'},
  4169.         $$::g_pSetupBlob{'CGI_EXT'});                    # the cart script URL
  4170.     #
  4171.     # go through the list backwards looking for a page
  4172.     # that doesn't match our script reg exp
  4173.     #
  4174.     for($i = $#$pPageList; $i >= 0; $i--)
  4175.         {
  4176.         if($$pPageList[$i] !~ m#^$sScriptURL#)        # if the start doesn't look like one of our scripts
  4177.             {
  4178.             return($$pPageList[$i]);                    # assume this is a catalog page
  4179.             }
  4180.         }
  4181.     return($sRefPage);                                    # return our default page
  4182.     }
  4183.  
  4184. ##############################################################################################################
  4185. #                                                                        
  4186. # File Read Calls - End
  4187. #
  4188. ##############################################################################################################
  4189.  
  4190. ##############################################################################################################
  4191. #                                                                        
  4192. # Blob Write Library - Begin
  4193. #
  4194. ##############################################################################################################
  4195.  
  4196. #######################################################
  4197. #                                                                        
  4198. # OpenWriteBlob - open the blob for write access
  4199. #    If the specified filename is empty, use STDOUT.
  4200. #    Note that STDOUT mode buffers the message and
  4201. #  writes on Close using HTTP header
  4202. #
  4203. # Params:    0 - filename - if filename == '',
  4204. #                    then use standard out
  4205. #
  4206. # Returns:    0 - status
  4207. #                1 - error message
  4208. #
  4209. # Affects:    WBFILE - file handle
  4210. #                $s_WBBuffer - file buffer
  4211. #                $ACTINIC::s_WBStyle - the blob style
  4212. #                    = $ACTINIC::FILE - file
  4213. #                    = $ACTINIC::STDOUT - STDOUT
  4214. #                    = $ACTINIC::MEMORY - memory
  4215. #
  4216. #######################################################
  4217.  
  4218. sub OpenWriteBlob
  4219.     {
  4220. #? ACTINIC::ASSERT($#_ == 0, "Invalid argument count in OpenWriteBlob ($#_)", __LINE__, __FILE__);
  4221.     
  4222.     my ($sFilename) = @_;
  4223.     
  4224.     if (length $sFilename > 0 &&                        # if we are writting to a file, open it
  4225.          $sFilename ne "memory")
  4226.         {
  4227. #?     ACTINIC::ASSERT(undef, "This path is potentially not secure - can we remove it?", __LINE__, __FILE__);
  4228.         SecurePath($sFilename);                            # make sure only valid filename characters exist in $file to prevent hanky panky
  4229.         unless (open (WBFILE, ">$sFilename"))        # open the file
  4230.             {
  4231.             return ($::FAILURE, "Unable to open $sFilename for writing: $!\n", 0, 0);
  4232.             }
  4233.         
  4234.         binmode WBFILE;                                    # make sure the file is written in binary mode
  4235.  
  4236.         $ACTINIC::s_WBStyle = $ACTINIC::FILE;                                # writing to file
  4237.         }
  4238.     elsif ($sFilename eq "memory")
  4239.         {
  4240.         $ACTINIC::s_WBBuffer = '';                                    # clear the buffer
  4241.         $ACTINIC::s_WBStyle = $ACTINIC::MEMORY;                            # writing to memory
  4242.         }
  4243.     
  4244.     return ($::SUCCESS, '', 0, 0);
  4245.     }
  4246.  
  4247. #######################################################
  4248. #                                                                        
  4249. # WriteBlob - write the blob
  4250. #
  4251. # Params:    0 - \@FieldList - reference to an array
  4252. #                    of field values to store
  4253. #                1 - \@FieldType - ref to an array of field
  4254. #                    types (in the same order as FieldList
  4255. # Returns:    0 - status
  4256. #                1 - error message
  4257. #
  4258. # Expects:    WBFILE - file handle
  4259. #
  4260. #######################################################
  4261.  
  4262. sub WriteBlob
  4263.     {
  4264. #? ACTINIC::ASSERT($#_ == 1, "Invalid argument count in WriteBlob ($#_)", __LINE__, __FILE__);
  4265.  
  4266.     my ($FieldList, $FieldType) = @_;
  4267.     
  4268.     my ($Field, $Type, @Response, $i);
  4269.     for($i = 0; $i <= $#{$FieldList}; $i++)        # loop over the fields in the table
  4270.         {
  4271.         $Type = $$FieldType[$i];                        # the field data type
  4272.         $Field = $$FieldList[$i];                        # the field value
  4273.         
  4274.         if ($Type == $::RBBYTE)                            # this field is a byte
  4275.             {
  4276.             @Response = WriteByte($Field);            # Write the byte
  4277.             }
  4278.         elsif ($Type == $::RBWORD)                        # this field is a Word
  4279.             {
  4280.             @Response = WriteWord($Field);            # Write the Word
  4281.             }
  4282.         elsif ($Type == $::RBDWORD)                    # this field is a double word
  4283.             {
  4284.             @Response = WriteDoubleWord($Field);    # Write the double word
  4285.             }
  4286.         elsif ($Type == $::RBQWORD)                    # this field is a Java long (64 bits)
  4287.             {
  4288.             @Response = WriteQuadWord($Field);        # Write the QuadWord
  4289.             }
  4290.         elsif ($Type == $::RBSTRING)                    # this field is a string
  4291.             {
  4292.             @Response = WriteString($Field);            # Write the string
  4293.             }
  4294.         else                                                    # unknown field type
  4295.             {
  4296.             return ($::FAILURE, "Unknown field type $Type\n", 0, 0); # return error
  4297.             }
  4298.         
  4299.         my ($Status, $Message);
  4300.         ($Status, $Message) = @Response;                # extract the results
  4301.         
  4302.         if ($Siel, 2)###
  4303. Rrase)                                # );            #f thed,ld type
  4304.             {
  4305.             re;
  4306.         ($Status, $ESS, "", 0# b th 0, 0);
  4307.             }
  4308.         }
  4309.     
  4310.     return ($::SUCCESS, '', 0, 0);
  4311.     }
  4312.  
  4313. #######################################################
  4314. #                                                            tes o            
  4315. # Writeup and clote the blob
  4316. #
  4317. # Returns:    0 - status
  4318. #                1 - error message
  4319. #    ffer - file busage
  4320. #
  4321. # E ffects:    WBFILE - file handle
  4322. #                $ACTINIC::s_WBSflag Searcy toler    if ($ arfects: handle
  4323. #                $ACTINI        $s_WBBuath to t- filee val
  4324. #                $ACTINIC::s_W!BStyle = $ACTINI)f if OK
  4325. #
  4326. #######################################################
  4327. es o            
  4328. # WrssIndex
  4329.     {fer
  4330.         $ACTINIC::s_WBBStyle = $ACTINI)e                                en the file
  4331.  
  4332.     {
  4333.     fects:Phrase');
  4334.         }
  4335.     else                                    ing to memr})
  4336.         {
  4337.         return ($::SUCCES
  4338. #                $ACTINI        $s_W $!", 0, 0);
  4339.         }
  4340.     
  4341.     return ($::SUCCESS$sError);
  4342.     }
  4343.  
  4344. ##############################################################################################################
  4345. #                                                                        
  4346. # Blob Write Liballs - End
  4347. #
  4348. ##############################################################################################################
  4349.  
  4350. ##############################################################################################################
  4351. #                                                            Low Le tl
  4352. # Blob Write Library - Begin
  4353. #
  4354. ##############################################################################################################
  4355.  
  4356. #######################################################
  4357. #                                                            onse = WriteBlob -eld is a blob
  4358. #
  4359. # Paramd is    # Ba read/weldList
  4360. # Returns:    0 - status
  4361. #                1 - error message
  4362. #
  4363. # Ex
  4364. #                $ACTINIC::s_WBSSearcy toleFILE s:    0 - statusfects:    WBval
  4365. #                $ACTINIC::s_WBBStyle = $ACTINI handle
  4366. #                $ACTINI        $s_WBBuval
  4367. #                $ACTINIC::s_W!BStyle = $ACTINI handle
  4368. #
  4369. #######################################################
  4370.  
  4371. sube the Blob
  4372.     {
  4373. #? ACTINIC::ASSERT($#_ == 0, "Invalid argument coonse = WriteBlob ($#_)", __LINE__, __FILE__);
  4374.     
  4375. SIZ:FA$= WrFA$2ExemptD    
  4376. SIZ:nPro            last;                            decletailsmwith t file tge)= WreldType) =$2Exe    for() = @_;2Exe    fo            #  unpack= Wree) = @_;
  4377.     fer
  4378.         $ACTINIC::s_WBBStyle = $ACTINI)e                                                    # if we ae writting tondex++)
  4379.         {
  4380.         uURL =rfects:A$2ExemMORY;                        nd clot to a numype
  4381.             {
  4382.             return ($::FAI
  4383.     my $we ae wramd is    # Be sure twriting: $ site.");
  4384.             }
  4385.         }
  4386.     else                                                        # if dumpe writt usiemory")
  4387.         {
  4388.         $ACTINIC::s_WB.=A$2Exe:MEMORY;        ap < $path to th# Be suar the bufory
  4389.         }
  4390.     
  4391.     return ($::SUCCESS, '', 0, 0);
  4392.     }
  4393.  
  4394. #######################################################
  4395. #                                                                        
  4396. he QiteBlob -elhe Qi concies (nd is    e sameacte####lds iup up the filb
  4397. #
  4398. # Parames our Ba read/weldList
  4399. # Returns:    0 - status
  4400. #                1 - error message
  4401. #
  4402. # Ex
  4403. #                $ACTINIC::s_WBSSearcy toleFILE s:    0 - statusfects:    WBval
  4404. #                $ACTINIC::s_WBBStyle = $ACTINI handle
  4405. #                $ACTINI        $s_WBBuval
  4406. #                $ACTINIC::s_W!BStyle = $ACTINI handle
  4407. #
  4408. #######################################################
  4409.  
  4410. suhe QuadBlob
  4411.     {
  4412. #? ACTINIC::ASSERT($#_ == 0, "Invalid argument coonse he QiteBlob ($#_)", __LINE__, __FILE__);
  4413.     
  4414. SIZ:FA$W$sPas$2ExemptD    
  4415. SIZ:nPr2            last;                            decletailsmwith t file tge)W$sPassword) =$2Exe    for() = @_;2Exe    fo            #  unpackW$sPae) = @_;
  4416.     fer
  4417.         $ACTINIC::s_WBBStyle = $ACTINI)e                                                    # if dumpe writting tondex++)
  4418.         {
  4419.         uURL =rfects:A$2ExemMORY;                        nd clot to a numype
  4420.             {
  4421.             return ($::FAI
  4422.     my $we ae wrames our Be sure twriting: $ site.");
  4423.             }
  4424.         }
  4425.     else                                            # if dumpe writt usiemory")
  4426.         {
  4427.         $ACTINIC::s_WB.=A$2Exe:MEMORY;        ap < $pa path to thar the bufory
  4428.         }
  4429.     
  4430.     return ($::SUCCESS, '', 0, 0);
  4431.     }
  4432.  
  4433. #######################################################
  4434. #                                                                        
  4435. = WriteDouiteBlob -eldwe Qi concies (nd is    e sam####acterlds iup up the filb
  4436. #
  4437. # Paramte the doubur Ba read/weldList
  4438. # Returns:    0 - status
  4439. #                1 - error message
  4440. #
  4441. # Ex
  4442. #                $ACTINIC::s_WBSSearcy toleFILE s:    0 - statusfects:    WBval
  4443. #                $ACTINIC::s_WBBStyle = $ACTINI handle
  4444. #                $ACTINI        $s_WBBuval
  4445. #                $ACTINIC::s_W!BStyle = $ACTINI handle
  4446. #
  4447. #######################################################
  4448.  
  4449. su= WriteDouuadBlob
  4450.     {
  4451. #? ACTINIC::ASSERT($#_ == 0, "Invalid argument coonse = WriteDouiteBlob ($#_)", __LINE__, __FILE__);
  4452.     
  4453. SIZ:FA$DW$sPas$2ExemptD    
  4454. SIZ:nPr4            last;                            decletailsmwith t file tge)DW$sPassword) =$2Exe    for() = @_;2Exe    fo            #  unpackDW$sPae) = @_;
  4455.     fer
  4456.         $ACTINIC::s_WBBStyle = $ACTINI)e                                                    # if dumpe writting tondex++)
  4457.         {
  4458.         uURL =rfects:A$2ExemMORY;                        nd clot to a numype
  4459.             {
  4460.             return ($::FAI
  4461.     my $we ae wramte the doubur Be sure twriting: $ site.");
  4462.             }
  4463.         }
  4464.     else                                            # if dumpe writt usiemory")
  4465.         {
  4466.         $ACTINIC::s_WB.=A$2Exe:MEMORY;        ap < $pa path to thar the bufory
  4467.         }
  4468.     
  4469.     return ($::SUCCESS, '', 0, 0);
  4470.     }
  4471.  
  4472. #######################################################
  4473. #                                                                        
  4474. te the QiteBlob -eld is a Java long (6i concies (####d is    e sameacterlds iup up the filb
  4475. #
  4476. # Paramqe t doubur Ba read/weldList
  4477. # Returns:    0 - status
  4478. #                1 - error message
  4479. #
  4480. # Ex
  4481. #                $ACTINIC::s_WBSSearcy toleFILE s:    0 - statusfects:    WBval
  4482. #                $ACTINIC::s_WBBStyle = $ACTINI handle
  4483. #                $ACTINI        $s_WBBuval
  4484. #                $ACTINIC::s_W!BStyle = $ACTINI handle
  4485. #
  4486. #######################################################
  4487.  
  4488. sute the QuadBlob
  4489.     {
  4490. #? ACTINIC::ASSERT($#_ == 0, "Invalid argument coonse te the QiteBlob ($#_)", __LINE__, __FILE__);
  4491.     
  4492. SIZ:FA$te the Qas$2ExemptD    
  4493. SIZ:nPr8            last;                            decletailsmwith t file tge)te the Qassword) =$2Exe    for() = @_;
  4494.     @= Wrt, @ark= Wrs[0]    for(    last;                             long  a Ja            modhrases otenfile.  supprk= Wrs[1]    for() =k= Wrs[2]    for() =k= Wrs[3]    for() =k= Wrs[4]    foe)te the Q & hex("ff000000ilena        >> 24() =k= Wrs[5]    foe)te the Q & hex("ff0000ilena        >> 16() =k= Wrs[6]    foe)te the Q & hex("ff00ilena            >> r8    ) =k= Wrs[7]    foe)te the Q & hex("ff"))() = @_;2Exe    fo            #  un8b (@= Wrt, @ar @_;
  4495.     fer
  4496.         $ACTINIC::s_WBBStyle = $ACTINI)e                                                    # if dumpe writting tondex++)
  4497.         {
  4498.         uURL =rfects:A$2ExemMORY;                        nd clot to a numype
  4499.             {
  4500.             return ($::FAI
  4501.     my $we ae wram8nd is    doubur Be sure twriting: $ site.");
  4502.             }
  4503.         }
  4504.     else                                                        # if dumpe writt usiemory")
  4505.         {
  4506.         $ACTINIC::s_WB.=A$2Exe:MEMORY;        ap < $pa path to thar the bufory
  4507.         }
  4508.     
  4509.     return ($::SUCC', 0, 0);
  4510.     }
  4511.  
  4512. #######################################################
  4513. #                                                                        
  4514. rator CteBlob -elad the stterlds up the filb
  4515. #
  4516. # Paramad the r Ba read/weldList
  4517. # Returns:    0 - status
  4518. #                1 - error message
  4519. #
  4520. # Ex
  4521. #                $ACTINIC::s_WBSSearcy toleFILE s:    0 - statusfects:    WBval
  4522. #                $ACTINIC::s_WBBStyle = $ACTINI handle
  4523. #                $ACTINI        $s_WBBuval
  4524. #                $ACTINIC::s_W!BStyle = $ACTINI handle
  4525. #
  4526. #######################################################
  4527.  
  4528. suSe the stBlob
  4529.     {
  4530. #? ACTINIC::ASSERT($#_ == 0, "Invalid argument coonse rator CteBlob ($#_)", __LINE__, __FILE__);
  4531.     
  4532. Sator as$2Exeragment, $nst, $iSator assword) =$2Exe    for() =        }
  4533.         $nLe
  4534.     if (lSator () = @_;
  4535.     @ge) = @Rnst,     {
  4536.             @Response = Writment, $nsMORY;                        nd cload the useful le
  4537.     #
  4538. {
  4539.             @Rose   memr})
  4540.         {
  4541.         r@ge) = @Rns    $/$1 /;                            # ifphraReturn a, b th 0, E);
  4542.         }
  4543.     
  4544. = Wrent, $nst, 
  4545. = Wrent, $nPr2 *agment, $;                                        i]} =ilses thalenas fi2nd iss@ar @_;
  4546.     f
  4547. = Wrent, $n$nRe    $/$1 /;                            # if thins
  4548. d the to t memr})
  4549. }
  4550.     
  4551. P        # (@orShellCha site.")
  4552.     P        #    $sRa".    f
  4553. = Wrent, $n/ 2 $sBuff)            # unpate the str;2Exe    fo            #  
  4554. P        # (iSator asite.")
  4555.     P        #    $sRC".f
  4556. = Wrent, $;                                                    # unpaSearvidthe  shell chara        @orShellChanLength =  
  4557. P        # (i2ExemptD    .")
  4558.     P        #    $sRxC" x     f
  4559. = Wrent, $n/ 2 $sBu# ces     # locat        #    
  4560. d the xCxCxC...
  4561. #    Notnd
  4562. #  eithe    i]} =ile the str;2Exe    fo            #  
  4563. P        # (@orShellCha sBuff)            # unpae    i]} =ile the strlts
  4564.         
  4565. er
  4566.         $ACTINIC::s_WBBStyle = $ACTINI)e        # dumpe written the file
  4567.                 {
  4568.         uURL =rfects:A$2ExemMORY                        nd clorawite the strire
  4569.                 {
  4570.                 return ($::FAI
  4571.     my $we ae wramad the r Be sure twriting: $ site.");
  4572.             wn tree
  4573.     
  4574. = Wrent, $n$n4096)1)                                        #seems!! needwed mithe  how a Javnumbmad the weecure  read/trire
  4575.                 {
  4576.                 return ($::FAI
  4577.     my $we ae wramad the stterlds up t:mad the  th".de Name
  4578.     "\n\t to be longe4K
  4579. #                b fiy b rase and y $b rae blob ing: $ site.");
  4580.             ng
  4581.             }
  4582.         else                                dumpe writt usiemorch?
  4583.                 {
  4584.         $ACTINIC::s_WB.=A$2Exe:MEMORY        ap < $pa path ar the buf0);
  4585.             }
  4586.         }
  4587.     
  4588.     return ($::SUCC$sError);
  4589.     }
  4590.  
  4591. ##############################################################################################################
  4592. #                                                            Low Le tl
  4593. # Blob Write Liballs - End
  4594. #
  4595. ##############################################################################################################
  4596.  
  4597. #####################################################asswor 0,InSot a-or 0,tch our Sot lyasswoalue.  This fage ame s!! ncurr Sot .pmallUtil asswoIfnfiwrit to         #                 execu comments stch our 
  4598. #   Sot asswoalue\" lee __);ysUND, which only   # fottine surIf the spasswoth t fileDetailrShed) asswoO                wi@Re'se ce' swisn't(sealu"Invalid a)
  4599. #    eaceck requi againrue are rn sose lik littintus == $::FiOUND was rqui agaifa    }
  4600. #         0,t# this is u     0,u     # ch ourequi aqui aAer of argu     turnsh our s u     0,gu     
  4601. #    se ce swisn'gu     2eldList - referenptional lth t fileD! needlrShedpt na status
  4602. #    unpath ourequi a le paand: ('$foo','$bla')#                 cters lrSh sostusfooittintusblave call)return ($::ittintus == $::FetailrShed autoandi whiyve calist
  4603. # gu     turns  0 - status       1 - error mprompt st aqui agai     0,t# texecu cd ( ||        # 
  4604. # Sot a errClose     0,)ur woqui ar    if ($ttin   1 - error mesultwe've stter     0,equi a(gai      1 - error mactersur worr    if ($, thiwaysntus == $::)qui agai'se ce' flag S  writtinSot .pma- this se notr worr    if (qui aval
  4605. us == $::equi agaiSot .pmadet
  4606. # enpviolonfigur    if ($, t
  4607. us == $::messagee
  4608. a        to:qui agai$th Value\" co
  4609.    #tolerh our:qui a},
  4610. t
  4611.             $s"!!!!!! T}
  4612. t
  4613.         ";qui a},
  4614. t
  4615.         1    $s"!!!!!! T}
  4616. t
  4617.         1";qui aerrors rets = $::SUCt aqui ar woqui a}
  4618.     
  4619. Rt the$Stasg asswr 0,InSot ($th ,TRUE : $,'$
  4620. t
  4621.         C$sErt aqui a                 errors rets = $:: statusgaiSot .pmaactersur wor},
  4622. t
  4623.             ! Tsetacter},
  4624. t
  4625.         1    irameters notatusgaiSot .pmamodule does nour worbont l        #setErt aqui a}
  4626.     
  4627. Rt the$Stasg asswr 0,InSot ($th ,TRUE : $,'$
  4628. t
  4629.         C,'$
  4630. t
  4631.         1C$sErt aqui aerrorss eturn ($::ittinsetsr},
  4632. t
  4633.             ttintus
  4634. t
  4635.         1Ert aqui a}
  4636.     
  4637. Rt the$Stasg asswr 0,InSot ($th ,TRUN ? ,'$
  4638. t
  4639.         C$sErt aqui aerrorss eturn ($::ittinsetsr},
  4640. t
  4641.             iaiSot .pmaactersqui aerrorss etu == $::Fetinsetsre rn soso                wi@RmessageeRysze stZyb No  Mnas24 18:09:02 GMT 2000messageeCopyright (c)                        # ASoftwl        #Ltd (2000)#####
  4642.  
  4643. #####################################################as###
  4644. r 0,InSot urePath
  4645.     {
  4646. LastNony $nam =le);        h our s u     0,guh
  4647.     {bFe ce ny $nam =le);    gainrue dangene surt namSot ure        #
  4648.         l        #ny $nam =le);    Rist - referenptional llrShed th t file tg        #
  4649. Rt theFILE__        #
  4650.         eval 'rSot '=le);    Trned ncurr Sot .pm @_;
  4651. ( $@ )e                                Canhis sinot t; $i--)
  4652.         {    {bFe ce )sKey)                unnot a     0,t# tse bPromptHimype
  4653.             {
  4654.             return ($::FAICanhis curr Sot .pm"$sValue);    # mes on , $!));
  4655.         Rt theny      0,({
  4656. LastNo$sValo                wi@R jswor        th     0,guh            }
  4657.         }
  4658.     else    # Sot ase no memr})
  4659. }
  4660. $pC        $nC - tSot ()(    last;                            Sot aalue\" le;
  4661.         pC        ->lrShe_stte(' (or',['$rn ($::C,'$rn ($::']", 0# AiwaysnlrSheur wand wo;
  4662.         pC        ->lrShe_stte(' (or',
  4663.         l        ilename);                l        #th t fileDIf the spas
  4664.         Rt theny     pC        ->r     0,({
  4665. LastNo$sVname);        r 0,tunpath ourguh            }
  4666. ;
  4667. ( $@ )e                                I                # if thins:  0 - error met!! Thises on , $!{as
  4668.         Rt theny     tus = $::FAILU");
  4669.         }
  4670.     r
  4671. Rt the$.  '                    de next 0);
  4672.     }
  4673.  
  4674. #######################################################
  4675. #                                                             calls-adebuwrir' inf this fu lhe kse ||        # t na st    ser looigu            # 9876 okingup the filb
  4676. #
  4677. # PtURL =  "rw"yptionaalue\"  sos error n error.
  4678. aC - lss r! Thutoandi whiy    ap < $s changed
  4679. #
  4680. #####################################################?###
  4681.  call###?tBlob
  4682. $|nPro    ###?t
  4683.     {
  4684. RequireMiptURL = s$nam in(',() = @#?twhILE 
  4685. er
  4686.         $ACTIbTr' iSockFirssCorr) @#?ttBlob
  4687.                 {
  4688.         $ACTIbTr' iSockFirssCorrny     tus : $ptD    .")b
  4689.         }
  4690.     
  4691. can te,
  4692.         #espoadd $sEpadd $sEproto$sElss )ptD    .")b
  4693.         
  4694. can te#ny '    #
  4695. lhost';")b
  4696.         
  4697.             #  #ny 9876;")b
  4698.         ee
  4699.                 # =~ /\D/) @#?tttBlob
  4700.             
  4701.             # = getser by($sF(
  4702.         #es'tcp') @#?ttt}")b
  4703.         ee
  4704. !
  4705.         #) @#?tttBlob
  4706.                 {
  4707.      @#?ttt}")b
  4708.         ee
  4709. !(poadd  = ss t_aton    
  4710. can te))) @#?tttBlob
  4711.                 {
  4712.      @#?ttt}")b
  4713.         Epadd  #ny sockadd _in(
  4714.         #espoadd )ptD    .")b
  4715.         
  4716. proto #ny getprotoby($sF('tcp')     @#?tt__);
  4717.     no srm t';")b
  4718.         ee
  4719. !socket(DBOUT, PF_INET, SOCK_STREAM$sEproto)) @#?tttBlob
  4720.                 {
  4721.      @#?ttt}")b
  4722.         ee
  4723. !alun
  4724. #(DBOUT, Epadd )) @#?tttBlob
  4725.                 {
  4726.      @#?ttt}")    .")b
  4727.         
  4728.     {
  4729.         $ACTIbTr' iSockeeny     tuN ? ;#####?        URL =rDBOUT    "\n\n"     @#?tt}#####?    whILE 
  4730. !
  4731.     {
  4732.         $ACTIbTr' iSockeen&& @#?ttt  
  4733.     {
  4734.         $ACTIbTr' isif FirssCorr) @#?ttBlob
  4735.                 {
  4736.         $ACTIbTr' isif FirssCorrny     tus : $ptDb
  4737.         }
  4738. elsif ($sFi=
  4739.  
  4740. sub (</B>'output.txt';")b
  4741.          calls Chang('rw', rePath($sFil")b
  4742.         _);
  4743.         SecurePath($sFilename);;                            # make sure only valid filename characters exist in $file to prevent hanky b
  4744.         nless DBOUT, BFILE, ">$sFil     @#?tt}##.")b
  4745.     URL =rDBOUT    {
  4746. RequireM.    "\n"     @#?t 0);
  4747.     }
  4748.  
  4749. #######################################################
  4750. #                                                            ecause -adebuwrecause f this fuhe filb
  4751. #
  4752. # Paramalu"infigulenamea    }
  4753. ,
  4754.     # w ref 
  4755. # Nobstittatus
  4756. #     error messocapprverified wi 
  4757. # Nobstittatus2eldlss rturns:    ack to 
  4758. # Nobst i- status3    WBFILE alue\"  sos 
  4759. # Nobstittnged
  4760. #
  4761. #####################################################?e fibrecause###?e tBlob
  4762.      }
  4763.     
  4764. bTeFieldsatus, $ES$nLss , rePathassword) b
  4765.      ee
  4766. !
  4767. bTeFi)) b
  4768.      tBlob
  4769.                  {
  4770.         $ACA
  4771. # NoIs                veny     tuN ? ;##b
  4772.          }
  4773. elT
  4774.             $s'A
  4775. # Nobst f thed:odule.
  4776. RequireM.    ' (dule.
  4777.             
  4778. .joinlss :odule.nLss 
  4779. .jo)';#####?e s
  4780.         
  4781. er
  4782.         $ACA
  4783. # NoIsLoope w)) b
  4784.      ttBlob
  4785.              }
  4786. ele ReS DOS;##b
  4787.              ele ReS DOS    $se ReS DOS();##b
  4788.               call(elT
  4789.             .
  4790. ele ReS DOS);##b
  4791.              actt;##b
  4792.              }lob
  4793.                  {
  4794.         $ACA
  4795. # NoIsLoope wny     tuN ? ;#####?
  4796.           call(elT
  4797.         );##b
  4798.          }
  4799. ele ReS DOS;##b
  4800.          ele ReS DOS    $se ReS DOSHTML();##b
  4801.                  {
  4802.         TerminalET
  4803.             .
  4804. ele ReS DOS);##b
  4805.          }lob
  4806.       0);
  4807.     }
  4808.  
  4809. #######################################################
  4810. #                                                            t ReS DOS    #                ); # a, whiur    i to check
  4811. #
  4812. # Read the  whiur    i t string ethe w
  4813.    #s:nto '_' (or,dlss rturns:sageef this f,dlss rturns:sageery thf this f,dlss rturns:sag    ..n errrror nthf this f,dlss rturns:sagnged
  4814. #
  4815. #####################################################?###
  4816. t ReS DOS###?tBlob
  4817.     }
  4818. @ whiu=  whier(1)    ###?t
  4819.     {lss ry      whi[2]    ###?t
  4820.     {c        $nC2;#####?    }
  4821. @s DOS;#####?    whILE 
  4822. RE, "Un(     whi[0])) @#?ttBlob
  4823.         
  4824.     {cwhierry      whi[0]    ###?t    @ whiu=  whier({c        l     @#?tt     whi[3]    fo{cwhierree
  4825. !RE, "Un(     whi[3])l     @#?ttunnnam (@s DOS,      whi[3]    .    ", B    .
  4826. elss )ptD#?tt    lss ry      whi[2]    ###?t    {c        ++     @#?tt}###?t
  4827.         }
  4828.     ) {" "\ring: @s DOS)l     @#?t 0);
  4829.     }
  4830.  
  4831. #######################################################
  4832. #                                                            t ReS DOSHTML    #                ); # a, whiur    i ts exHTML    "rw"ypstringo check
  4833. #
  4834. # Read the  whiur    i t string eth exHTML    e w
  4835.    #s:nto '_'t Re S DOS:nto '_'    * (or*,dlss rturns:sagee    *f this f*,dlss rturns:sagee    *ry thf this f*,dlss rturns:sag        ..n err    *rror nthf this f*,dlss rturns:sagnge    Terifytthe r    i ts sound nprverifieb    #
  4836. k qu te#anotr w####a This fa>$sFeDetaietined n requinged
  4837. #
  4838. #####################################################?###
  4839. t ReS DOSHTML###?tBlob
  4840.     }
  4841. ele ReS DOS    $s\"") "") t Re S DOS:<BLOCKf (!N ""
  4842.             "e ReS DOS() $_[1]BLOCKf (!N "     @#?tele ReS DOS    $~ s/\rin/"") .rin""
  4843. /g     @#?tele ReS DOS    $~ s/,/\<\/B\>,/g     @#?t
  4844.         }
  4845.     ree ReS DOS);##b
  4846. def);
  4847.     }
  4848.  
  4849. #######################################################
  4850. Inde highlightthe s This fquinged
  4851. #
  4852. ##########################################################################################################################Highlight= Wrad Chighlights
  4853. #    If the spew Wradfields HTML###s 
  4854. ireMssions usimments stmarkupuhe filb            
  4855. # Input:    sp' insehiddprvetional lw Wrad $fhighlight status
  4856. #        highlightsif themarkup status
  4857. #    2   highlights< $pmarkup stIn/Output: 3eldList - referelds HTMLD! needturns:    m.woale status
  4858. #        turns:caobst i-lik li'\w\w' iequinged
  4859. #
  4860.  WARNING WARNING WARNING WARNING WARNING ######################Teri
  4861.    #tole]} =imodule do
  4862.    #le rinl                        # A]} toler    iuse ss.####Te!!!! T]} =ilenaPer        exp NoeDet 11AMet partamad  Javponal lcoffee!filb    t!! ThiIf thhe      0 -self-ile totole]} =irifierun-e havg n configuhe filb            ! Tsd  Jalyopriamm< $s 
  4863. #    Notyouoprview
  4864. ires 72-73ew mode Bield         t mel.#Te!!!u ("P"s'PATTERN'CODE_TO_CREATE_REPLallMENT'resi"message exploitden - is thhe  the Nobesvnumbm"sionLE qu te"    e waaded miterequinged
  4865. #
  4866.  WARNING WARNING WARNING WARNING WARNING ##########################################################################################
  4867. Highlight= Wra
  4868.    Blob
  4869.     {
  4870. #? ACTINIC::ASSERT(3#_ ==            # inchidden pargumentHighlight= Wra(ompt) {" . join(_) $_[).b ($#_)", __LINE__, __FIL  a}
  4871.     
  4872. s= Wra, reSf th$statnQas$rsHTMLassword)   a#)   a# Now,tHighlightthe w Wra..n e  a#)   a}
  4873. @Pd the 
  4874.         @a)d)   a#)   a# Ahiur    rty seshouldneedile                    # s is usionLE-sp' inded miters)   a# Butsintsthe  whItesp' in'\w     0 -locate         #  sose lims);     in e  a#)   a}
  4875. @= Wrad=sintsth/\s+?/,
  4876. s= Wrad)   alena(@= Wra))   a   Blo  a   # Mesn'taord gin  sosl lw Wra.#Te!!!shouldn- fileusionLEilename chlo  a   # w Wradrifi Err            blems!-acter        # ort des (nookinhiuhyphenpprver Wra
  4877.       # t pag    {
  4878. alue\"  sos n aposd  phert here bag    {
  4879.     modhras'\w"\b".
  4880.       #
  4881.       # Butsxtracthe  thblemidden aor
  4882. s= Wra    iramete is ty-escaprvetiketr w##;;        HTML    e $ph- re: "O'Reilly"ilenaO'Reilly". UT.
  4883. #        {
  4884.     modXML/SGML##      #  is tbes,ametened r    HTML    "%xx"ok la.#Ben$, thi"rw"yprelotolee  "$_".
  4885.       #
  4886.       s/\'/\'/g    MORY        aposd  pher'\woesn'tld the : O'Reilly
  4887.       s/-/\-/g    MORY        hyphenr'\woesn'tld the : Difs:    -Hellman
  4888.       s/\./\./g    MORY        s);iodr'\woesn'tld the : www.a                # .cte##      s/_/ /g    MORYBu# conv No '_'is usp' in'\wld the : Big_A_Auto
  4889.       #
  4890.       # Conv N permiw=imort deanr s uconsid r: !&;:$%*
  4891.       #
  4892.                 I        e - nprg_W $avoid highlightsb"rwk sos n XMLilename che is ty
  4893.                 tiket"{".#Te!!!! Tmetet res);     in!-abm";"i
  4894.    #toler w##;;         nprg_Wfile to s highlightthe         #e toree
  4895. meteXML.#Teribess six##;;            eval '!!unr
  4896.   ions usigloba        er\w' inttin xFor silyeaceckthe str                    s thaoesn'tef, "rnal lins:is ty. Butsxt!!!shouldnc# loomonot ex#ew mode pame i whw     0  scri            }
  4897.         Highlights<xt< $ad $fdoubube noarbesv
  4898. #  lhw     0  scri            }
  4899.  
  4900.         
  4901. _$sVal/^\d+$/64 bits)
  4902.         # Me            # makeoubube noary!! Tmete";"it partInprg_W)
  4903.         #
  4904.           push
  4905. @Pd the 
  4906. (-1,\b$_\[^;\]*?,\b(?!;)"sError);
  4907.             }
  4908.         e_ilen''64 bits)
  4909.           push
  4910. @Pd the 
  4911. (-1,\b$_.*?,\b"sError);
  4912.       })   a#)   a# Orig
  4913.         T George iamm< asese\" l chanain!-aB                Birxt!!el, 11 Mey 2000me    #)   a# do                 loostuf
  4914.         assume thiliter    T qu te#stterBen' T]} =ilenamyouoASSEr)                #ih$siamm< asck t))   a#)   a# Youoaskerase #ih! -brface  a#)   a# w=imort deanr s ualtloop ovs tlnew mode p, $ESso w=isll wa, opyce  a#)   a$$rsHTML$sVal~(<s tln>.+?</s tln>)~isFIL  a}
  4915. $sOldT tlne= $1d)   a#)   a# W        # bss tute#an "untikel useg# Atoken"message fs tln. Si refee f'!' i- sY        anded miterv
  4916. #  dva reinseInde,age fsoken!shouldn)        y    e wuntikel ue w t; $#fphrabeesse are re: assum                "P"PR(!NCTTITLE"itact er lver Wr.ce  a#)   a$$rsHTML$sVas~(<s tln>.+?</s tln>)~!PR(!NCTTITLE!~gisFIL  a}
  4917. $sPd the d)   a#)   a# Tbuild the aracterab# l, i.n. w Wradd gin  sosrified wioesn'tr    rty .)   a# Tbuirrg_xw"\b$_.*?,b"FiOUNDwhiy    msse tiket"\b\w+?"dfields      0 -of)   a# w WradlenamTRACEis all we doesFor silyesixe$path escaprvenvalid char)   a#)   aesse tha$sPd the a(@Pd the 
  4918. ))   a   Blo  a   $$rsHTML$sVas'\>(.*?)\<'lo  a      #
  4919.         a# see WARNING ab# l..nassume t        # if thel lcodavg n config
  4920.         a# unpaSea< aaobst i-l            # inc- sionLE qu tes fielded mitervtiket"{"lo  a      #
  4921.         a# E                # extrat
  4922.             betwee#  dj' inhemarkup tagschange$1.
  4923.         a# Mins
  4924. < $pup ($1ilena") t p($1i=~ /\s/)racterPer        should
  4925.         a# valcksurIeInde-misoesn't n
  4926. #        {
  4927.     nyw    y    viae
  4928.     if (aceckthe.
  4929.         a# Si refeesume thigloba        er\w' i,         #                 e# sis potenre"rw"
  4930.         a# unpaHTML$lenae thald the p- o(nooki$#Pd the 
  4931.     l l1 t p2,     f
  4932.         a# wnly   #used bmsse longen ao,age f++)        shouldneedpriansid red.
  4933.         a# en.
  4934. highlightthe,bmsse longe3 t p4useyneedunes (RE, "    nyw    y.
  4935.         a# Butsa#  dva reinseIndesrifietand esn't mnal li mun'tlargchlo  a     a# group l lld the arcouldn erro.lo  a      #
  4936.         a}
  4937. $te= $1d)   a  a   $t    $~ s/($sPd the )/reSf th$1tatnQ/gsi;lo  a      #
  4938.         a# Re-in# No xtrat
  4939.         ,amew    # mre noonly uhighlightson/off,    betwee#)
  4940.         # xtraorig
  4941.         T markup tagscrifiemarkup ded miters siorefee forig
  4942.         T)
  4943.         # his ishemis useIndelo  a      #
  4944.         a">$t<";lo  a      #
  4945.         a# see WARNING ab# l..nry thlss r! Tlds upniselo  a   'resi;age                                 # ' ##Te!!!sionLE qu tesed minpprs string  sos            blems!rifieemacs;
  4946.       })   a# Reues t xtraorig
  4947.         T s tln. Iecurt diseg#s rwh uhnd ed met!higloba    )   a# er\w' inBuath who thedetactli#  wriuniqu n ss. Buts esn'FeDeb# l.ce  a#)   a$$rsHTML$sVas~!PR(!NCTTITLE!~$sOldT tln~gisFIL  a}##########################################################################Dn paminePricesToShow -lhe kt mnamTRACEpricesis ushowd/weldList
  4948. # Re($bShowRse\"lPrices, $bShowCuuesmerPrices, $nAy the Sn'FUtil) handle
  4949. DEN ? $oki$tus : $nookibShowXXX handleval
  4950. bShowCuuesmerPrices, r wor}nAy the Sn'FUtilValue\" cosn'FUtilVID###########################################################################
  4951. Dn paminePricesToShowurePath URL
  4952. N!!!!! nwe kt mnamTRACEpricesis ushowd/l etc
  4953.     #nAy the Sn'FUtilV= -1;guh
  4954.     {bShowCuuesmerPricesny     tus : $ptD    
  4955.     {bShowRse\"lPricesny     tuN ? ;##h URL
  4956. See                        sume thisuuesmerify the account}
  4957. $sDigess BStyle = $ACB2B->Get('wordDigess'ath2(@_($sDigess len''64 biode
  4958.         {
  4959.         Getpath ary_W)
  4960.     #        }
  4961.         
  4962.         my ($Status, $, EpBry_Wasswyle = $ACGetBry_W($sDigess,wyle = $ACGetsub (<", 0,oesn'up tth ary_W)
  4963.     
  4964.         
  4965.         if ($=tatus != $::SUCCESS)
  4966.         #)
  4967.         # Gotpath ary_WSso getpath fy the acc        #)
  4968.         }
  4969. $pAy the sError
  4970.         my ($Status, $, EpAy the asswyle = $ACGetCuuesmerAy the     retBry_W{Ay the ID},wyle = $ACGetsub (<",wn tree
  4971.             if ($=tatus != $::SUCCESre
  4972.                 #
  4973.                 # Gotpath fy the Sso getpath sn'FUtilV            #whe|        # ese\"lEpricesietailrown
  4974.                 #
  4975.                 ;
  4976. ( $pAy the ->{PriceSn'FUtil}W!BS1 )         I        ese\"lE!! Tmetern our de Namee
  4977.                     #nAy the Sn'FUtilV= $pAy the ->{PriceSn'FUtil}, 0# sll wath sn'FUtil
  4978.                     #bShowRse\"lPricesny !etBry_W->{HedeRse\"lPrices};0# sll wwhe|        # wailrow ese\"lEprices
  4979.                     #bShowCuuesmerPricesny     tuN ? ;                                            #lrow suuesmeriprices
  4980.                     }ite.");
  4981.             ng
  4982.             }
  4983.         }
  4984.     rbShowRse\"lPrices, $bShowCuuesmerPrices, $nAy the Sn'FUtil)sError);
  4985.     }
  4986.  
  4987. ###############################################################
  4988. #Vh t nt\@FieldGetpath vh t ntetionaernam        ); tdTypeHTML$lenaiamptannthe filb            
  4989. #     [0]    --locate ); tdTypt - red/weldList
  4990. # Re($Vh t nt\@Fi$staLss ) handle
  4991. Vh t nt\@FieldList - referenptional lth t  argu ndle
  4992. Lss     -eHTML$lenate ); tdTyp###########################################################################
  4993.  
  4994. #Vh t nt\@FirePath2
  4995.     {
  4996.     e ); tRefassword) = @_;
  4997. Vh t nt\@Fi$staLss $stkesponse, $i)e tha$k (keys %,
  4998.                 
  4999. Hash); $i--)
  5000.         {    {S    $~ /^(_?)
  5001.     e ); tRef\_/ SUCCESS)
  5002.         }
  5003. $sVh t ntSpecny     llUtilt
  5004.     {c        $nC$sVh t ntSpecny~ tr/_/_/;                     Cthe SASSEr)            es
  5005.                     {    {c        $n= 0 )last;                            N rn sos-            #te            VALUEUCCESre
  5006.                 
  5007. Vh t nt\@Fi->[$sVh t ntSpec]ny     tu
  5008.                 
  5009. Hash{$k}site.")taLss B.=A"<INPUT TYPE=HIDDEN AR:U=eturne ); tRefompt"_ompt"$sVh t ntSpec\"    VALUE=etutu
  5010.                 
  5011. Hash{$k}\">"site.");
  5012.                     }
  5013. {    {c        $n= 1 )last;                # Jswortand-abmsi        to      0 UCCESre
  5014.                 
  5015.     {
  5016. Attrictee,
  5017.     my ($sVaintst('_',$sVh t ntSpec site.")
  5018. Vh t nt\@Fi->[$sAttrictee]$nC$sVhy (site.")taLss B.=A"<INPUT TYPE=HIDDEN AR:U=eturne ); tRefompt"_ompt"$sAttrictee\"    VALUE=etun ("\"$s>"site.");
  5019.                     }}
  5020.     else                                    Msse longetand-as     lo    T attricteesv
  5021. # tandwidgetUCCESre
  5022.                 
  5023.     @sVh SpecItems!Vaintst('_',$sVh t ntSpec site.")$i);spo=r($i <=$#sVh SpecItemsldLis=2)de Namee 
  5024.                     #Vh t nt\@Fi->[$sVh SpecItemseldL]$nC$sVh SpecItemseld+1];
  5025.                     #aLss B.=A"<INPUT TYPE=HIDDEN AR:U=eturne ); tRefompt"_ompt"$sVh SpecItemseldL\"    VALUE=etun ( SpecItemseld+1]$s>"site.")    }ite.");
  5026.             ng
  5027.             }
  5028.         }
  5029.     rVh t nt\@Fi$staLss ) undef);
  5030.     }
  5031.  
  5032. #######################################################Cuuesmerify the ssiammst f This fsquinged
  5033. #
  5034. ##################################################################################################################Cfy GetCwardes!-agetpyle = $_ACCOUNTaernayle = $_BASEcts:Acwardesd/weldList
  5035. # nput:    fy the Scwardee field #tus
  5036. #        b    0 -FILE alardee field #f OK
  5037. #
  5038. #######################################################
  5039. fy GetCwardesrePath2
  5040.     {
  5041. Cwardesernamardes_FILE__);
  5042. returt -rsswyle = $ACGetturt  -r(nst, 
  5043. eturt -rss~ s/\?.*//;                                    WFileedsck t jswore sure thed filnstringfig
  5044.         }
  5045. ;
  5046. ( yle = $ACIeSf ticn($s(
  5047. eturt -r) )                I                i-l    $sFilcterano                ur    ific
  5048. ireM-            sume tmeteB2Bemory")
  5049.         {
  5050.         $ACB2B->C                ('B    0             
  5051. 'ath2(
  5052.         {
  5053.         $ACB2B->C                ('wordIDamarde'ath2(
  5054.         {
  5055.         $ACB2B->C                ('wordN$sF'ath2(
  5056.         {
  5057.         $ACB2B->Set('C                IDamarde','CLEAR'$sValC                 nticaamardeery the hah2(
  5058.         {
  5059.         $ACB2B->Set('C                nticamarde','CLEAR'$sValC                 nticaN$sFaamardeery the hah2(
  5060.  
  5061.         }
  5062.     r'',''", 0, 0);
  5063. rnamardesny     tuENV{' usi_COOKIE'}    MORY        trned nr
  5064.         # Retriealarde @_;
  5065.     @amarde($pPageLintst(/;/sernamardes_F 0# sehiddprpath vh tous alardee f t fileDfields o page2
  5066.     {
  5067. Label,$sDigess,$sB    0             
  5068. ,urne ); t            
  5069. ,urwordN$sF_FILE__esse tha$samardee    @amarde($pPaemory")
  5070.     samardees~ s/^\s*//;                            TMODE)    rip              tolewhIteusp' ipShop);
  5071.     amardees~ /^yle = $_ACCOUNT/Rrase)            se notr w    fy the ScwardeUCCESS)
  5072.         {
  5073. Label,
  5074. $sDigessageLintst (/=/sernamarde_F 0# r
  5075.         # Retrie field va    #)
  5076.         # )    rip ed btr\"ltoleer              tolequ te($ttinsp' isd va    #)
  5077.         $sDigess B~ s/^\s*"?//;)
  5078.         $sDigess B~ s/"?\s*$//;)
  5079.         );
  5080.             }
  5081.         elamardees~ /^yle = $_USERAR:U/)se)            se notatalhed fUCCESS)
  5082.         {
  5083. Label,
  5084. $swordN$sF_geLintst (/=/sernamarde_F 0# r
  5085.         # Retrie field va    #)
  5086.         # )    rip ed btr\"ltoleer              tolequ te($ttinsp' isd va    #)
  5087.         $swordN$sFsswyle = $ACDecodaT
  5088.         ($swordN$sFES
  5089. #                $ACFORMob{'_ENCODED);)
  5090.         $swordN$sFss~ s/^\s*"?//;)
  5091.         $swordN$sFss~ s/"?\s*$//;)
  5092.                 {
  5093.         $ACB2B->Set('wordN$sF',urwordN$sF_FIL
  5094.         );
  5095.             }
  5096.         elamardees~ /^yle = $_BASEcts:/)se)            se notath a    0 -FILEUCCESS)
  5097.         {
  5098. Label,
  5099. $sB    0             
  5100. _geLintst (/=/sernamarde_F # r
  5101.         # Retrie field va    #)
  5102.         # )    rip ed btr\"ltoleer              tolequ te($ttinsp' isd va    #)
  5103.         $sB    0             
  5104. sswyle = $ACDecodaT
  5105.         ($sB    0             
  5106. ,S
  5107. #                $ACFORMob{'_ENCODED);)
  5108.         $sB    0             
  5109. ss~ s/^\s*"?//;)
  5110.         $sB    0             
  5111. ss~ s/"?\s*$//;)
  5112.         );
  5113.             }
  5114.         elamardees~ /^yle = $_PRODUCTPAG:/)se)        se notath                             lailrown
  5115.             S)
  5116.         {
  5117. Label,
  5118. $sne ); t            
  5119. _geLintst (/=/sernamarde_F # r
  5120.         # Retrie field va    #)
  5121.         # )    rip ed btr\"ltoleer              tolequ te($ttinsp' isd va    #)
  5122.         $sne ); t            
  5123. sswyle = $ACDecodaT
  5124.         ($sne ); t            
  5125. ,S
  5126. #                $ACFORMob{'_ENCODED);)
  5127.         $sne ); t            
  5128. ss~ s/^\s*"?//;)
  5129.         $sne ); t            
  5130. ss~ s/"?\s*$//;)
  5131.                 {
  5132.         $ACB2B->Set('ne ); tn($s',urne ); t            
  5133.  site.");
  5134.             }
  5135. ;
  5136. ( !$sDigess )last;                                         I                # if thno Digess                     # lhwo                uatalhth t file tgry")
  5137.         {
  5138.         $ACB2B->C                ('B    0             
  5139. 'ath2(
  5140.         {
  5141.         $ACB2B->C                ('wordIDamarde'ath2(
  5142.         {
  5143.         $ACB2B->C                ('wordN$sF'ath2(
  5144.         {
  5145.         $ACB2B->C                ('wordDigess'ath2(
  5146.  
  5147.         }
  5148.     r'',''", 0, 0);
  5149.         }
  5150.     r
  5151. sDigess,$sB    0             
  5152. ) undef);
  5153.     }
  5154.  
  5155. ################################################### CAccLogi p- nticalory - B NoInvalid aseldLisval '!: Digess::MD5ilenam        sume tmetese notoutputthins:  0 -ttin xiargu     a  a   $tu
  5156.                 
  5157. HashileedeD! needletaceessegu     a  a   $tuENV{ usi_REFERER}gu     a  a   Phr    0  e - th"rw" y - B filb    f  whiu    $sFilcterlory 
  5158. ireMss  eMD5itovg n cone digessfilb            #ia< aify unpaetic. filb    n            i-l    $0 -$tu
  5159.     sB2BwordIDamarde    ttintus
  5160. _sB    0             
  5161. sl        #set.####O                wi@Reaceck ACCOUNTaalardeeag\" ctuatalho pa.eldList
  5162. # ne suriguriwrits.###K
  5163. #
  5164. #######################################################
  5165. AccLogi rePath2
  5166.     {
  5167. Digess,$sB    0             
  5168. ,uMd5_FILE__        {
  5169.         $ACB2B->C                ('wordIDamarde'ath2(        {
  5170.         $ACB2B->C                ('B    0             
  5171. amarde'ath2    }
  5172. ;
  5173. ( $tu
  5174.                 
  5175. Hash{USER}    ttintus
  5176. _            
  5177. Hash{HASH} )l        I                i-l    $sFilcterLOGINcatalog py")
  5178.         #
  5179.         eval 'rDigess::MD5';e);    TrnecurrtoleMD5, drop dew" gr' ifuotennamet!! TnotpathripShop);
  5180. @   mem    S)
  5181.             {
  5182.         $ACPRL =n($s(yle = $ACGetshr    0 (-1, 211, 
  5183. @ , ASSERT(    tus : $ site."actt;##    tt}####        $sDigess Bntus
  5184. _            
  5185. Hash{HASH}th2(
  5186.         {
  5187.         $ACB2B->Set('wordIDamarde',$sDigess)th2(
  5188.         {
  5189.         $ACB2B->Set('wordN$sF',utu
  5190.                 
  5191. Hash{USER})th2(
  5192.         {
  5193.         $ACB2B->Set('wordN$sFamarde',    {
  5194.         $ACEncodaT
  5195.         2(tyle = $ACB2B->Get('wordN$sF'a,0))th2(
  5196.         {
  5197.         $ACB2B->Set('B    0             
  5198. ',yle = $ACGetturt  -r(n)th2(
  5199.         {
  5200.         $ACB2B->Set('B    0             
  5201. amarde',    {
  5202.         $ACEncodaT
  5203.         2(tyle = $ACB2B->Get('B    0             
  5204. 'a,0))th2(
  5205.         }
  5206.         } memr})
  5207. }
  5208. $eturt -rsswyle = $ACGetturt  -r(nst,  
  5209. eturt -rss~ s/\?.*//;                                    WFileedsck t jswore sure thed filnstringfig
  5210. -)
  5211.         {    yle = $ACIeSf ticn($s(
  5212. eturt -r) )                I                i-l    $sFilcterano                ur    ific
  5213. ireM-            sume tmeteB2Bemorch?
  5214.             sDigess Bn""er = '';                C                      loyrn so)
  5215.                 {
  5216.         $ACB2B->C                ('B    0             
  5217. 'ath2(
  5218.  
  5219.         {
  5220.         $ACB2B->C                ('wordIDamarde'ath2(
  5221.  
  5222.         {
  5223.         $ACB2B->Set('C                IDamarde','CLEAR'$sValC                 nticaamardeery the hah2(
  5224.  
  5225.         {
  5226.         $ACB2B->Set('C                nticamarde','CLEAR'$sValC                 nticaN$sFaamardeery the hah2(
  5227.     ng
  5228.             }
  5229.  
  5230.             S)
  5231.         {
  5232. Digess,$sB    0             
  5233. )sswyle = $AC
  5234. fy GetCwardes(_F 0# See                        euatalhooggeth exhi"rw"yh2(
  5235.  
  5236.         {
  5237.         $ACB2B->Set('B    0             
  5238. ',$sB    0             
  5239. ) und.");
  5240.             }__);
  5241.     
  5242. Samy ($Stsatus, $, EpBry_Wasswyle = $ACGetBry_W($sDigess,wyle = $ACGetsub (<", 0,oesn'up tth ary_W)
  5243.  
  5244.         
  5245.         if ($Siel, 2)###
  5246. n&& @en i        if ($Siel, NOTFOUND64 biode
  5247.         {
  5248.         Dup tth                     < ary!!nmode p, $ptiona $fhelp tth ae n ipSho        {
  5249. push
  5250. (@tu
  5251.     n($s\@Fi$sttu
  5252.     n($s\@Fi[$#tu
  5253.     n($s\@Fi]) und.;
  5254.     
  5255. Samy ($Stsatus, $, EsHTMLasswyle = $ACist
  5256. #ToLas=n($s(7, "<FONTaSIZ:=\"+2$s>"ule.
  5257. RequireM.    "</FONT>",wyle = $ACGetshr    0 (-1, 141),de Name
  5258.  
  5259.  
  5260.  
  5261.  
  5262.  
  5263.  
  5264.  
  5265.  
  5266.  
  5267.  
  5268.  
  5269.  
  5270.  
  5271.  
  5272.  
  5273.  
  5274. \@tu
  5275.     n($s\@Fi$sttu
  5276.     sWebSiteUrl,de Name
  5277.  
  5278.  
  5279.  
  5280.  
  5281.  
  5282.  
  5283.  
  5284.  
  5285.  
  5286.  
  5287.  
  5288.  
  5289.  
  5290.  
  5291.  
  5292.  
  5293. ttu
  5294.     sConh isUrl,sttu
  5295.     pSetup            
  5296. , %,
  5297.                 
  5298. Hash);lts
  5299.         
  5300.         if ($Siel, 2)###
  5301. R mem    S)
  5302.             {
  5303.         $ACRe
  5304.         #erminalEatus, $, yle = $ACGetsub (<",wn tr}####        yle = $ACUpdoneDiintay(EsHTML,sttu
  5305.     Orig
  5306.         T            
  5307. 2Exera\@tu
  5308.     n($s\@Fi",wn tactt;##    t}h2    }
  5309. ;
  5310. ( $sDigess && @en i        if ($Siel, NOTFOUND6 '';                Finotath atal memr})
  5311. }
  5312. $pAy the sErro    
  5313. Samy ($Stsatus, $, EpAy the asswyle = $ACGetCuuesmerAy the     retBry_W{Ay the ID},wyle = $ACGetsub (<",wn t
  5314.         
  5315.         if ($Siel, 2)###
  5316. R mem    S)
  5317.         #)
  5318.         # Dup tth                     < ary!!nmode p, $ptiona $fhelp tth ae n ipSho    #)
  5319.         push
  5320. (@tu
  5321.     n($s\@Fi$sttu
  5322.     n($s\@Fi[$#tu
  5323.     n($s\@Fi]) und..;
  5324.     
  5325. Samy ($Stsatus, $, EsHTMLasswyle = $ACist
  5326. #ToLas=n($s(7, "<FONTaSIZ:=\"+2$s>"ule.
  5327. RequireM.    "</FONT>",wyle = $ACGetshr    0 (-1, 141),de Name
  5328.  
  5329.  
  5330.  
  5331.  
  5332.  
  5333.  
  5334.  
  5335.  
  5336.  
  5337.  
  5338.  
  5339.  
  5340.  
  5341.  
  5342.  
  5343.  
  5344.  \@tu
  5345.     n($s\@Fi$sttu
  5346.     sWebSiteUrl,de Name
  5347.  
  5348.  
  5349.  
  5350.  
  5351.  
  5352.  
  5353.  
  5354.  
  5355.  
  5356.  
  5357.  
  5358.  
  5359.  
  5360.  
  5361.  
  5362.  
  5363.  ttu
  5364.     sConh isUrl,sttu
  5365.     pSetup            
  5366. , %,
  5367.                 
  5368. Hash);lts
  5369. t
  5370.         
  5371.         if ($Siel, 2)###
  5372. R mem    re
  5373.                     {
  5374.         $ACRe
  5375.         #erminalEatus, $, yle = $ACGetsub (<",wn trr}####            yle = $ACUpdoneDiintay(EsHTML,sttu
  5376.     Orig
  5377.         T            
  5378. 2Exera\@tu
  5379.     n($s\@Fi",wn t"actt;##    tt}####        ;
  5380. ( $EpAy the {        if (}W!BS0 )last;##Cuuesmerify the uris < $s chem    S)
  5381.             {
  5382.         $ACPRL =n($s(yle = $ACGetshr    0 (-1, 214, $EpAy the {Ay the N$sF} , ASSERT(    tus : $ site."actt;##    tt}##
  5383.             }
  5384.          retBry_W{        if (}W!BS0 )last# Buyerify the uris < $s chem    S)
  5385.             {
  5386.         $ACPRL =n($s(yle = $ACGetshr    0 (-1, 215, retBry_W{N$sF},$EpAy the {Ay the N$sF} , ASSERT(    tus : $ site."actt;##    tt}##
  5387.             {
  5388.         $ACB2B->Set('wordDigess',$sDigess)th2##
  5389.     
  5390. fy SetCceckouttrings(etBry_W, EpAy the aptD    .")
  5391. yle = $AC
  5392.  
  5393.     {
  5394. CuuesmerAddrtusISSEx(", 0,TbuisuuesmeriSea<xme tleft nlesslenamulti    to awritsESso                 nmet!up thripSho        }
  5395.         }
  5396.     else                                    Netese no memr})
  5397. }
  5398. $eRequireMipyle = $ACGetshr    0 (-1, 216aptD    .RecorderminsalEatus, $, yle = $ACGetsub (<",a# ercouburth e  0 -erelds e  0 -FILEUCCE    {
  5399. push
  5400. @tu
  5401.     n($s\@Fi$syle = $ACGetturt  -r(nst,  ;
  5402.     
  5403. Samy ($StsErn a, EsHTMLasswyle = $ACist
  5404. #ToLas=n($s(7, "<FONTaSIZ:=\"+2$s>"ule.
  5405. RequireM.    "</FONT>",wyle = $ACGetshr    0 (-1, 208),de Name
  5406.  
  5407.  
  5408.  
  5409.  
  5410.  
  5411.  
  5412.  
  5413.  
  5414.  
  5415.  
  5416.  
  5417.  
  5418.  
  5419.  
  5420.  
  5421.  
  5422. \@tu
  5423.     n($s\@Fi$sttu
  5424.     sWebSiteUrl,de Name
  5425.  
  5426.  
  5427.  
  5428.  
  5429.  
  5430.  
  5431.  
  5432.  
  5433.  
  5434.  
  5435.  
  5436.  
  5437.  
  5438.  
  5439.  
  5440.  
  5441. ttu
  5442.     sConh isUrl,sttu
  5443.     pSetup            
  5444. , %,
  5445.                 
  5446. Hash);lts
  5447.         
  5448.         if ($Siel, 2)###
  5449. R mem    S)
  5450.             {
  5451.         $ACRe
  5452.         #erminalEErn a, yle = $ACGetsub (<",wn tr}##E    {
  5453. PRL =n($s(EsHTML,sASSERT(    tuN ? ",wn tactt;##    t}h2t 0);
  5454.     }
  5455.  
  5456. #######################################################
  5457. #                                                            tAy CExeoogBodyeldLit
  5458. # ned fiof  (orl    $xeoog p, $phe filb
  5459. #
  5460. # are neeldList
  5461. # nut:    htmlure thed fiare lld a status
  5462. #  1    --locas$sFile th                    # if    modhrilc$sFeDeu"Inilc$sFeetile th                    # if    mod #f OK
  5463. #
  5464. #######################################################
  5465. Ay CExeoogBodyurePath
  5466.     {
  5467. ne ); tn($s    $s'    $xeoogbody.html';                        de our   amelaead/t URL
  5468. See                        # if thi  amelaea        evaessfit URL;
  5469. ( $tu
  5470.                 
  5471. Hash{PRODUCTPAG:}i=~ /\S/ SUCCEy")
  5472.     sne ); tn($s    $s$tu
  5473.                 
  5474. Hash{PRODUCTPAG:};;
  5475.             }__);
  5476. $sFc$sFn($s    $s$sne ); tn($s;    }
  5477. ;
  5478. ( yle = $ACIeCExeoogFc$sFd() SUCCEy")
  5479.     sFc$sFn($s    $s'lc$sFeet.html';                    de our   amelaea!rifielc$sFe 0, 0);
  5480.         }
  5481.     r
  5482. sne ); tn($s,    sFc$sFn($s) undef);
  5483.     }
  5484.  
  5485. #######################################################Cfy SetCceckouttrings    --Setpath dse\"lsmessage thary_W)
  5486. ####erelds cceckoutileingshe filb            
  5487. nput:    Type! nery_W)
  5488. #tus
  5489. #  1    --Type! nfy the ac#f OK
  5490. #
  5491. #######################################################
  5492. fy SetCceckouttringsrePath2
  5493.     {
  5494. tBry_W, EpAy the assword) = @_;
  5495. Samy ($Stsatus, $, EpInvoiceAddrtus, EpDeli loyAddrtus, EnInvoiceAddrtusID, EnDeli loyAddrtusID);)
  5496.  URL
  5497. Setpath fddrtus IDeD! nASSERis rqu
  5498.  URLEnInvoiceAddrtusIDV= -1;guhEnDeli loyAddrtusIDV= -1;gu)
  5499.  URL
  5500.  
  5501. #0 -locataxilnstringfig
  5502.      URL                    # O samACP
  5503. #0 Adva reiTax();)
  5504.  URL
  5505. Setpath Compnayileings-erelds fy the ued fUCC URLEtu
  5506.     B            Conhact{'REMEMBERME'}ny     tus : $ptD     URL
  5507. Setpath Comped bleings-erelds fy the ued fUCC URLEtu
  5508.     B            Conhact{'COMPANY'}ny     pAy the ->{Ay the N$sF}FILE__);
  5509. (%Payid aInst);)
  5510.  URL
  5511. Setpath prurt  -dlldyid a methodit partgeg  sosunpate the st# er\ct e aaobst f errCe!!nmode p,yid a haseloC URLEPayid aInst{'METHOD'}n        =                     # O samACEnumToPayid aSator (    pAy the ->{De our Payid aMethod});)
  5512.  URL
  5513. Cceck                        eufy the ue sury   #s k li'\voice fddrtusfit URL;
  5514. (    pAy the ->{InvoiceAddrtusRtil}Wn= 1SUCCEy")
  5515.     nInvoiceAddrtusIDV=     pAy the ->{InvoiceAddrtus}FILE__LEtu
  5516.     B            Conhact{'AR:U'}        =     pAy the ->{N$sF}FIL_LEtu
  5517.     B            Conhact{'SALUTATION'}=     pAy the ->{Saluaaobst}FIL_LEtu
  5518.     B            Conhact{'JOBTITLE'}    =     pAy the ->{T tln}FIL_LEtu
  5519.     B            Conhact{'PHONU'}        =     pAy the ->{Telephk lNurns:}FIL_LEtu
  5520.     B            Conhact{'FAX'}            =     pAy the ->{FaxNurns:}FIL_LEtu
  5521.     B            Conhact{'EMAIL'}        =     pAy the ->{E (olAddrtus}FIL(
  5522.         }
  5523.         } memr})
  5524. ;
  5525. (    pBry_W->{InvoiceAddrtusRtil}Wn= 0R mem    S)
  5526.             nInvoiceAddrtusIDV=     pBry_W->{InvoiceAddrtusID};##    tt}####        $tu
  5527.     B            Conhact{'AR:U'}        =     pBry_W->{N$sF}FIL_LEtu
  5528.     B            Conhact{'SALUTATION'}=     pBry_W->{Saluaaobst}FIL_LEtu
  5529.     B            Conhact{'JOBTITLE'}    =     pBry_W->{T tln}FIL_LEtu
  5530.     B            Conhact{'PHONU'}        =     pBry_W->{Telephk lNurns:}FIL_LEtu
  5531.     B            Conhact{'FAX'}            =     pBry_W->{FaxNurns:}FIL_LEtu
  5532.     B            Conhact{'EMAIL'}        =     pBry_W->{E (olAddrtus}FIL(
  5533.         }
  5534.  URL
  5535. I                #kmew    unpaSevoice fddrtus populdprpath haseeserified wi ddrtusfit  dse\"lsfit URL;
  5536. (    nInvoiceAddrtusIDV!= -1SUCCEy")
  5537. ;
  5538. Samy ($Stsatus, $, EpInvoiceAddrtusassw)
  5539.             {
  5540.         $ACGetCuuesmerAddrtus(    pBry_W->{Ay the ID},w    pAy the ->{InvoiceAddrtusID},wyle = $ACGetsub (<",wn t
  5541.         
  5542.         if ($Siel, 2)###
  5543. R mem    S)
  5544.         
  5545.         }
  5546.     ) und.");
  5547.     Etu
  5548.     B            Conhact{'ADDR#
  5549. 1'}        =     pInvoiceAddrtus->{Lss 1}FIL_LEtu
  5550.     B            Conhact{'ADDR#
  5551. 2'}        =     pInvoiceAddrtus->{Lss 2}FIL_LEtu
  5552.     B            Conhact{'ADDR#
  5553. 3'}        =     pInvoiceAddrtus->{Lss 3}FIL_LEtu
  5554.     B            Conhact{'ADDR#
  5555. 4'}        =     pInvoiceAddrtus->{Lss 4}FIL_LEtu
  5556.     B            Conhact{'COUNTRY'}        =     {
  5557.         $ACGetCthe ryN$sF(
  5558. InvoiceAddrtus->{Cthe ryCode})th2(
  5559.     tu
  5560.     B            Conhact{'POSTALCODE'}    =     pInvoiceAddrtus->{PostCode};de
  5561.         {
  5562.         New    #etpath Sevoice     #
  5563. obst instringfig
  5564.     
  5565.         {
  5566.     tu
  5567.     L#
  5568. obstInst{INVOICE_COUNTRY_CODE}    =     pInvoiceAddrtus->{Cthe ryCode};    {
  5569.     tu
  5570.     L#
  5571. obstInst{INVOICE_REGION_CODE}        =     pInvoiceAddrtus->{        ifeCode};de
  5572.         {
  5573.         New    #etped btaxiexame bst to t mem#})
  5574. ;
  5575. (    tu
  5576.     pTaxSetup            
  5577. {TAX_BY}W!BS2R mem    S)
  5578.             tu
  5579.     TaxInst{'EXEMPT1'}n    =     pInvoiceAddrtus->{Exame Tax1}Wn= 0 ?i$tus : $n:     tuN ? ;##h            tu
  5580.     TaxInst{'EXEMPT2'}n    =     pInvoiceAddrtus->{Exame Tax2}Wn= 0 ?i$tus : $n:     tuN ? ;##h        ;
  5581. (    tu
  5582.     TaxInst{'EXEMPT1'}R mem    re
  5583.                     tu
  5584.     TaxInst{'EXEMPT1DATA'}n    =     pInvoiceAddrtus->{Tax1Exame 2Exe}site.");
  5585.             ;
  5586. (    tu
  5587.     TaxInst{'EXEMPT2'}R mem    re
  5588.                     tu
  5589.     TaxInst{'EXEMPT2DATA'}n    =     pInvoiceAddrtus->{Tax2Exame 2Exe}site.");
  5590.             }##    t}h2    }
  5591. ;
  5592. (    pBry_W->{Deli loyAddrtusRtil}Wn= 0R memy")
  5593.     nDeli loyAddrtusIDV=     pBry_W->{Deli loyAddrtusID};##    t;
  5594. Samy ($Stsatus, $, EpDeli loyAddrtusassw)
  5595.             {
  5596.         $ACGetCuuesmerAddrtus(    pBry_W->{Ay the ID},w    pAy the ->{Deli loyAddrtusID},wyle = $ACGetsub (<",wn    {
  5597.     tu
  5598.     ShipConhact{'AR:U'}        =     pBry_W->{N$sF}FIL_LEtu
  5599.     ShipConhact{'SALUTATION'}=     pBry_W->{Saluaaobst}FIL_LEtu
  5600.     ShipConhact{'JOBTITLE'}    =     pBry_W->{T tln}FIL_LEtu
  5601.     ShipConhact{'PHONU'}        =     pBry_W->{Telephk lNurns:}FIL_LEtu
  5602.     ShipConhact{'FAX'}            =     pBry_W->{FaxNurns:}FIL_LEtu
  5603.     ShipConhact{'EMAIL'}        =     pBry_W->{E (olAddrtus}FILIL_LEtu
  5604.     ShipConhact{'ADDR#
  5605. 1'}        =     pDeli loyAddrtus->{Lss 1}FIL_LEtu
  5606.     ShipConhact{'ADDR#
  5607. 2'}        =     pDeli loyAddrtus->{Lss 2}FIL_LEtu
  5608.     ShipConhact{'ADDR#
  5609. 3'}        =     pDeli loyAddrtus->{Lss 3}FIL_LEtu
  5610.     ShipConhact{'ADDR#
  5611. 4'}        =     pDeli loyAddrtus->{Lss 4}FIL_LEtu
  5612.     ShipConhact{'COUNTRY'}        =     {
  5613.         $ACGetCthe ryN$sF(
  5614. Deli loyAddrtus->{Cthe ryCode})th2(
  5615.     tu
  5616.     ShipConhact{'POSTALCODE'}    =     pDeli loyAddrtus->{PostCode};de
  5617.         {
  5618.         New    #etpath deli loy     #
  5619. obst instringfig
  5620.     
  5621.         {
  5622.     tu
  5623.     L#
  5624. obstInst{DELIVERY_COUNTRY_CODE}    =     pDeli loyAddrtus->{Cthe ryCode};    {
  5625.     tu
  5626.     L#
  5627. obstInst{DELIVERY_REGION_CODE}    =     pDeli loyAddrtus->{        ifeCode};de
  5628.         {
  5629.         New    #etped btaxiexame bst to t                        'rcatax sosby deli loy  ddrtusfitm#})
  5630. ;
  5631. (    tu
  5632.     pTaxSetup            
  5633. {TAX_BY}W=BS2R mem    S)
  5634.             tu
  5635.     TaxInst{'EXEMPT1'}n    =     pDeli loyAddrtus->{Exame Tax1}Wn= 0 ?i$tus : $n:     tuN ? ;##h            tu
  5636.     TaxInst{'EXEMPT2'}n    =     pDeli loyAddrtus->{Exame Tax2}Wn= 0 ?i$tus : $n:     tuN ? ;##h        ;
  5637. (    tu
  5638.     TaxInst{'EXEMPT1'}R mem    re
  5639.                     tu
  5640.     TaxInst{'EXEMPT1DATA'}n    =     pDeli loyAddrtus->{Tax1Exame 2Exe}site.");
  5641.             ;
  5642. (    tu
  5643.     TaxInst{'EXEMPT2'}R mem    re
  5644.                     tu
  5645.     TaxInst{'EXEMPT2DATA'}n    =     pDeli loyAddrtus->{Tax2Exame 2Exe}site.");
  5646.             }##    t}h2
  5647.  URL
  5648. sll wath turns:    m to t meount}
  5649.     {
  5650.             @Resp                    # O samACGetCar ID(yle = $ACGetsub (<",a# er
  5651.         # Retriea theID##t
  5652.         
  5653. {
  5654.             @Rose$Siel, 2)###
  5655. R                                    e  0 -out memr})
  5656.         {
  5657.         r@ge) = @Rns##    t}h2
  5658.  
  5659.     {
  5660. Car IDassw
  5661. {
  5662.             @Ro2]    ##        {
  5663.             @Resp                    # O samACSll CceckoutSamy ((yle = $ACGetsub (<sernaar ID, \%tu
  5664.     B            Conhact,de Name
  5665.  
  5666.  
  5667.  
  5668.  
  5669. \%tu
  5670.     ShipConhact, \%tu
  5671.     ShipInst, \%tu
  5672.     TaxInst, \%tu
  5673.     G n colInst,de Name
  5674.  
  5675.  
  5676.  
  5677.  
  5678. \%Payid aInst, \%tu
  5679.     L#
  5680. obstInst) undef);
  5681.     }
  5682.  
  5683. ################################################### CAccFinontica- sinotooggeth exatalhssionscwardeUCB NoInvalid aseldList
  5684. # nnticaDigess 0 -""ree
  5685. metese notoruris < $s chOK
  5686. #
  5687. #######################################################
  5688. Ay FinonticrePath2
  5689.     {
  5690. Digess,$sB    0             
  5691. )sswyle = $AC
  5692. fy GetCwardes(_F # See                        euatalhooggeth exhi"rw"y     le
  5693.     #
  5694. sDigess) memr})
  5695.         {
  5696.         r"");;
  5697.             }__);
  5698.     
  5699. Samy ($Stsatus, $, EpBry_Wasswyle = $ACGetBry_W($sDigess,wyle = $ACGetsub (<", 0,oesn'up tth ary_W)
  5700.  
  5701.         
  5702.         if ($Siel, 2)###
  5703. ) mem r})
  5704.          {
  5705.         r"");;
  5706.              }__);
  5707. $pAy the sErr    
  5708. Samy ($Stsatus, $, EpAy the asswyle = $ACGetCuuesmerAy the     retBry_W{Ay the ID},wyle = $ACGetsub (<",wn 
  5709.         
  5710.         if ($Siel, 2)###
  5711. ) memr})
  5712.         {
  5713.         r"");;
  5714.             }__);
  5715. ( $EpAy the {        if (}Wn= 0 && @en ietBry_W{        if (}Wn= 0 )last;    
  5716. Cceck                fy the u thi            ve tgry")
  5717.         {
  5718.         $ACB2B->Set('B    0             
  5719. ',$sB    0             
  5720. ) und.
  5721.         }
  5722.     r
  5723. sDigessilename);;        Fe notldLit
  5724. # digessfi
  5725.             }__)        {
  5726.         r"");;
  5727. ef);
  5728.     }
  5729.  
  5730. ################################################### P
  5731. #0 XML    #    PXML    wrap <W)
  5732. #tPrehid  e asicoth t fileDernam
  5733. #0 sat
  5734.             ssionsyle = $_PXML###sAer of a:    --ly theoam
  5735. #0 heck
  5736. #
  5737. # Re- P
  5738. #0 d-ly tchOK
  5739. #
  5740. #######################################################
  5741. P
  5742. #0 XMLurePath
  5743.     {
  5744. HTML$s $nam =unt}
  5745. $sDigess BStyle = $ACB2B->Get('wordDigess'ath2    }
  5746. ;
  5747. ( !$sDigess )lB NoIatal memr})
  5748. $sDigess BStyle = $ACB2B->Set('wordDigess',yle = $AC
  5749. Ay Finontic(<",L
  5750. See                        # if thi atalhalardeea partall##    t}h2    }
  5751. ;
  5752. ( $sDigess )                nticafe notlddo ssmee asicoXML    th t file tgry")
  5753. ;
  5754.     
  5755. Samy ($Stsatus, $, EpBry_Wasswyle = $ACGetBry_W($sDigess,wyle = $ACGetsub (<", 0,oesn'up tth ary_W)
  5756.  
  5757.         
  5758.         if ($Siel, 2)###
  5759. R mem    S)
  5760.             {
  5761.         $ACRe
  5762.         #erminalEatus, $, yle = $ACGetsub (<",wn tr}####        }
  5763. $pAy the sErro    
  5764. Samy ($Stsatus, $, EpAy the asswyle = $ACGetCuuesmerAy the     retBry_W{Ay the ID},wyle = $ACGetsub (<",wn t
  5765.         
  5766.         if ($Siel, 2)###
  5767. R mem    S)
  5768.             {
  5769.         $ACRe
  5770.         #erminalEatus, $, yle = $ACGetsub (<",wn tr}####        }
  5771. $sBuyeri= retBry_W{N$sF};##        }
  5772. $sAy the i= retAy the {Ay the N$sF}th2(
  5773.         {
  5774.         $ACB2B->SetXML('BUYER',  a   $sBuyer)th2(
  5775.         {
  5776.         $ACB2B->SetXML('ACCOUNT',  a $sAy the )th2(
  5777.         {
  5778.         $ACB2B->SetXML('NOWSERVING',wyle = $ACGetshr    0 (-1, 212, $sBuyer))th2(
  5779.         {
  5780.         $ACB2B->SetXML('CURRACCOUNT',yle = $ACGetshr    0 (-1, 213, $sAy the )M.    "<                    # :LOGOUT_SIMPLE/>")th2(
  5781.         {
  5782.         $ACB2B->SetXML('WELCOME',  a yle = $ACGetshr    0 (-1, 210, $sBuyer))th2h2(
  5783.         {
  5784.         $ACB2B->SetXML('LOGOUT', "</TR><TR><TD ALIGN=RIGHT>" @en M.    "<     HREF=etutu
  5785.     sAy the Sn our\?    {
  5786. ON=LOGOUT"ule($tu
  5787.                 
  5788. Hash{SHOP} ?i"&SHOP="ule    {
  5789.         $ACEncodaT
  5790.         2(ttu
  5791.                 
  5792. Hash{SHOP}T(    tus : $ n: a") .    "\" TARGET=et_hid nt$s>"wn trM.    "<"
  5793.         de Nam. yle = $ACGetshr    0 (-1, 217   mem    n M.    "</B></A></TD>")th2(
  5794.         {
  5795.         $ACB2B->SetXML('LOGOUT_SIMPLE', de Name
  5796.  
  5797.  
  5798.  
  5799. i" <     HREF=etutu
  5800.     sAy the Sn our\?    {
  5801. ON=LOGOUT&PATH=$tu
  5802.                 
  5803. Hash{PATH}\" TARGET=et_hid nt$s>"wn trme
  5804.  
  5805.  
  5806.  
  5807. i. yle = $ACGetshr    0 (-1, 217   mem    ne
  5808.  
  5809.  
  5810.  
  5811. i. "</A>");;
  5812.             }__);
  5813. $pXML$s  - tyle = $_PXML(_F # C"rwtodXML obj in e__)        {
  5814.         $pXML->P
  5815. #0 (EsHTML_F 0# 
  5816. #0 -l
  5817.             ttin        {
  5818.     ;
  5819. ef)
  5820.  
  5821. ########################################################### 
  5822. ick($s    yle = $_B2BtldkeepseB2B    th t file t# #Te!!!obj indkeepseB2B    th t fileate virtoleSet,lC                 ttinGetErt af This fsequi aSetXML,wyp < $XML,wGetXML ttinC                XML tre his is_);
  5823. sse essage  er
  5824.         # ReXML tag    th t fileahis ibytyle = $_PXML clats.###sageeRysze stZyb No  Mnas17 12:11:17 GMT 2000messageeCopyright (c)                        # ASoftwl        #Ltd (2000)#####
  5825.  
  5826. #####################################################as
  5827. ick($s    yle = $_B2B;;
  5828. rCe!;
  5829.     no;f)
  5830.  
  5831. ########################################################### 
  5832. ###
  5833.  - t- c"rwtodB2B    obj ind###sageeRysze stZyb No  Mnas17 12:11:50 GMT 2000messageeCopyright (c)                        # ASoftwl        #Ltd (2000)#####
  5834.  
  5835. #####################################################as#####
  5836.  - turePath
  5837.     {Proto s $nam =unt}
  5838. $Clorrny ref({Proto) ||    {Proto=unt}
  5839. $Self#ny {}th2(files    
  5840.     elf,
  5841. $Clorrath2(        elf->{XML}ny {}th2__)        {
  5842.         $    elf;;
  5843. ef)
  5844.  
  5845. ########################################################### 
  5846. B2B->Setd-as    teB2B    th t fil### 
  5847. Avalid aseld    Paramalorreld    P1    --th t filued fUC#us2eldth t filu field #tu
  5848. #
  5849. # eld    Paramth t filu field #tusageeRysze stZyb No  Mnas17 12:14:43 GMT 2000messageeCopyright (c)                        # ASoftwl        #Ltd (2000)#####
  5850.  
  5851. #####################################################as#####
  5852. SeirePath2
  5853.     $Self#s $nam =unt}
  5854. $sN$sFssw$nam =unt}
  5855. $s ("\"ssw$nam =unh2(        elf->{$sN$sF}$nC$sVhy (site        {
  5856.         $sVhy (siteef)
  5857.  
  5858. ########################################################### 
  5859. B2B->C                 - uns    teB2B    th t fil### 
  5860. Avalid aseld
  5861.          aramalorreld
  5862.          1    --th t filued fUC#sageeRysze stZyb No  Mnas17 12:19:09 GMT 2000messageeCopyright (c)                        # ASoftwl        #Ltd (2000)#####
  5863.  
  5864. #####################################################as#####
  5865. C                rePath2
  5866.     $Self#s $nam =unt}
  5867. $sN$sFssw$nam =unh2(        elf->{$sN$sF}$nCASSERsiteef)
  5868.  
  5869. ########################################################### 
  5870. B2B->Getd-ag    teB2B    th t fil### 
  5871. Avalid aseld
  5872.  
  5873.          aramalorreld
  5874.  
  5875.          1    --th t filued fUC#tu
  5876. #
  5877. # eld
  5878.  
  5879.          aramth t filu field #sageeRysze stZyb No  Mnas17 12:20:48 GMT 2000messageeCopyright (c)                        # ASoftwl        #Ltd (2000)#####
  5880.  
  5881. #####################################################as#####
  5882. GeirePath2
  5883.     $Self#s $nam =unt}
  5884. $sN$sFssw$nam =unt        {
  5885.         $    elf->{$sN$sF};;
  5886. ef)
  5887.  
  5888. ########################################################### 
  5889. B2B->SetXML    #    s    teB2B    XML    th t fil### 
  5890. Avalid aseld    Paramalorreld    P1    --th t filued fUC#us2eldth t filu field #tu
  5891. #
  5892. # eld    Paramth t filu field #tusageeIfmth t filu, thi"rw"ypSERis rimodule dh sos nddLit
  5893. # nins:mpty
  5894. #    rty .) # 
  5895. Updone    shouldneedhis is_)ile toracter sosth t file t#sageeRysze stZyb No  Mnas17 12:14:43 GMT 2000messageeCopyright (c)                        # ASoftwl        #Ltd (2000)#####
  5896.  
  5897. #####################################################as#####
  5898. SeiXMLurePath
  5899.     {Self#s $nam =unt}
  5900. $sN$sFssw$nam =unt}
  5901. $s ("\"ssw$nam =unh2(        elf->{XML}->{$sN$sF}$nC$sVhy (site        {
  5902.         $sVhy (siteef)
  5903.  
  5904. ########################################################### 
  5905. B2B->yp < $XMLt:    fp < $ead the s_)B2B    XML    th t fil### 
  5906. Avalid aseld
  5907.          aramalorreld
  5908.          1    --th t filued fUC#
  5909.          2eldad the s_)fp < $UC#tu
  5910. #
  5911. # eld
  5912.          aram - tth t filu field #sageeRysze stZyb No  Mnas17 12:19:09 GMT 2000messageeCopyright (c)                        # ASoftwl        #Ltd (2000)#####
  5913.  
  5914. #####################################################as#####
  5915. yp < $XMLurePath
  5916.     {Self#s $nam =unt}
  5917. $sN$sFssw$nam =unt}
  5918. $s ("\"ssw$nam =unh2(        elf->{XML}->{$sN$sF}$.nC$sVhy (site        {
  5919.         $    elf->{XML}->{$sN$sF}siteef)
  5920.  
  5921. ########################################################### 
  5922. B2B->GetXMLt:    g    teB2B    XML    th t fil### 
  5923. Avalid aseld
  5924.  
  5925.          aramalorreld
  5926.  
  5927.          1    --th t filued fUC#tu
  5928. #
  5929. # eld
  5930.  
  5931.          aramth t filu field #sageeRysze stZyb No  Mnas17 12:20:48 GMT 2000messageeCopyright (c)                        # ASoftwl        #Ltd (2000)#####
  5932.  
  5933. #####################################################as#####
  5934. GeiXMLurePath
  5935.     {Self#s $nam =unt}
  5936. $sN$sFssw$nam =unt        {
  5937.         $    elf->{XML}->{$sN$sF}siteef)
  5938.  
  5939. ########################################################### 
  5940. B2B->C                XML -                     # lhwB2B    XML    th t file t#sageeRysze stZyb No  Mnas17 12:23:28 GMT 2000messageeCopyright (c)                        # ASoftwl        #Ltd (2000)#####
  5941.  
  5942. #####################################################as#####
  5943. C                XMLurePath
  5944.     {Self#s $nam =unt        elf->{XML}ny ASSERsiteef)f)
  5945.  
  5946. ########################################################### 
  5947. PXML.pm    #        seudo    XML    m
  5948. #0 r t#sageeRysze stZyb No  Nov 28 09:30:40 GMT 1999messageeCopyright (c)                        # ASoftwl        #Ltd 1999mes##
  5949.  
  5950. #####################################################as
  5951. ick($s    PXML;;
  5952. rCe!;
  5953.     no;f)
  5954.  
  5955. ########################################################### 
  5956. PXML-> - () -     on;
  5957. uct0 -FenaPXML clats### 
  5958. A  loy r    iuse s     on;
  5959. uct0 . Ahi #s inherita re.) # 
  5960. e Res
  5961. Sei() a This fapa#  soset# lhwd wi valid asequi aSowd wi valid asuseyneedIf the spe    # ifrifieed f=> field #tupairs t pageyuseyneedI    teldprlhssionsSei() methodequi aNoInvalid as tre obligat0 y!!nm - () cter lhw valid asusussfilbneedIf the spebeesse P
  5962. #0 () method !!!u (dequi aF
  5963.    #tolenvalid as tre     eval 'd:sageeIDus
  5964. #  => prurixew moagsc! need- filed (ituseyneedIf the spe!nmP
  5965. #0 ())sageeoag1
  5966. #  => List - referea This fa $fh fileu<IDoag1>sageeoag1_E $e=> List - referea This fa $fh fileu</IDoag1>sagee..n er aSs thhe oe bstahw valid as:sageeDEFAULT  => List - refereaea This fah filtoleunercognised status
  5967. #       oagsc(rifieprurixeIf the spe!nmID)sageeXMLERROR => ermin mequireMeoamRL =wwhen    m
  5968. #0 r dseectthins:  0  status
  5969. #       Embedoonl%s#                 eedpr\w' i ibytlocatagdlenamTRACEins:  0  status
  5970. #       phradseect(dequi aaaaaaaaaaaaaDe our : "ermin m
  5971. #0toleXML t
  5972.             (%s)"sageeIfmDEFAULT e tmeteIf the spe        euankmewn oagsctre pa# s is_sageeoutputuanch fg requinge aSments sta This faseynin meynmetebe difst - o,age foagnge aed fianotath IDutre pa# s is_re sur This fequi aSee iamm< asFenaP
  5973. #0 ().###sageeRysze stZyb No  Dec  1    18:15:36 GMT 1999messageeCopyright (c)                        # ASoftwl        #Ltd 1999mes##
  5974.  
  5975. #####################################################as#####
  5976.  - turePath
  5977.     {Proto s $nam =unt}
  5978. $Clorrny ref({Proto) ||    {Proto=unt}
  5979. $Self#ny {}th2(files    
  5980.     elf,
  5981. $Clorrath2(        elf->{XMLERROR}ny "ermin m
  5982. #0toleXML t
  5983.             (%s)"th2(        elf->{LoopProtect}ny 25000th2(        elf->{Cur - oLoop}ny 0th2(        elf->Sei(@__FIL#    u{
  5984. alur    iut V N per => '4';__)        {
  5985.         $    elf;;
  5986. ef)
  5987.  
  5988. ########################################################### 
  5989. PXML->Sei() #    s    tealufiguconfigchidden pas t#sageeRysze stZyb No  Nov 28 09:34:32 GMT 1999messageeCopyright (c)                        # ASoftwl        #Ltd 1999mes##
  5990.  
  5991. #####################################################as#####
  5992. SeirePath2
  5993.     $Self#s
  5994. #  = $nam =unt}
  5995. %Pidden passsword) = URL
  5996. Sehiddprph fileraracterhidden pas amdm                eaehaseloC URLesse tha(keys %Pidden pas); $i--)
  5997.         {    ref({Pidden pas{$_})ilenaCODE" )lB T"rwtr lhwf This fsue wtagdh filerar(     0 -sensi        veR mem    S)
  5998.                 elf->{Tags}->{uc($_)}$nC$Pidden pas{$_};##    tt}##
  5999.             }e    else                                    Anyrn so         }ef thi hidden par(     0 -sensi        veR mem    S)
  6000.                 elf->{$_}$nC$Pidden pas{$_};##    tt}##
  6001.     })  
  6002. ef)
  6003.  
  6004. ########################################################### 
  6005. PXML->P
  6006. #0 () -    m
  6007. #0 -ly tchOtusageeNOTE: Ituseyneed whieddLicuN pvely
  6008. #### 
  6009.  
  6010. Avalid as:    arly theoam
  6011. #0 hec                    1 (oe bstah) IDu-eprurixeeoaoesn'f0  statu
  6012. #
  6013. # Re am
  6014. #0 d-ly tchOtusageeWhen    awtagdisafe no,aoesnsmessage f< $-tagdanotc Res
  6015. f This fsageemTRACEihradsclars is_rdthe rified i wtag. t# #Terat
  6016.             betwee# if th-tagdanot< $-tagdef, "rseddLicuN pvely
  6017. # #Tern (ifpSERis r)ea This fah fi so $tag.'_E $' i-l    whied. t# #Abbrevipprvesyntax: <tag/>u thi    cept(dequi aPidden passtre parseddernam
  6018. # s iaseaehase List - referer w##i ah filer (hidden parrifi Err fielu th#etpao 'SET'64 #### 
  6019. Tagdh fil so a This fai-l    whied!rifielivew valid as:sag            tag                -wtagded fUC#us\$sT
  6020.                     -wList - referer
  6021.             fe notbetwee# if thdanot< $foagnge
  6022.  
  6023. \%Padden pas    -wList - referehidden parhaseloe
  6024.  
  6025. ID                    -wprurixeessage thrunsag            eSf thTag        - fuoter
  6026.             w mif thdoagngesageeItuseyn        {
  6027.         ly theoagoheoaoutputuanotseynals_)ile torr w##i at
  6028.             betwee# oagscbeesse et!! Tparseddfur        # ngesageeIft< $-tagdh fil so a This fai-lSERis rir woret!! T    whiedsageea parttriealnh iss!! Tparsed.sageeIftmete-ret!de our s-erelagdh fil so a This f.sageeE $-tagdh fil so a This fai-l    whied!rifielocas$sFinvalid aseldLue wtagdh fil so a This factere suryrg 0, 3uanot4sl        #set.###### 
  6029. TageDernaIDutre      0 -sensi        vequi aPidden passn$sFeDere his iinehase anch fg rngesageeIftlocatagdh fil so a This fai-lmetern is rir wo:sageeIfmDEFAULT a This fai-lSERis ri-ret!! T    whiedsageeIfmDEFAULT_E $ea This fai-lSERis ri-ret!! T    whiedeessaE $-tagsageeO                wi@Relocatocatagd! Tpa# s i fa $foutputuanch fg requinge aRysze stZyb No  Nov 28 14:40:12 GMT 1999messageeCopyright (c)                        # ASoftwl        #Ltd 1999mes##
  6030.  
  6031. #####################################################as#####
  6032. P
  6033. #0 hePath2
  6034.     $Self#ss $nam =unt}
  6035. $sT
  6036.         ss $nam =unt}
  6037. $sId#  = $nam =un    }
  6038. ;
  6039. ( !$sId#) {
  6040. $sId#=    $    elf->{ID}; }                        IDuhidden par!!!oe bstahwthripSh}
  6041. $Resur =unh2(        elf->{Cur - oLoop}++;    }
  6042. ;
  6043. (         elf->{Cur - oLoop}n>         elf->{LoopProtect}nR memy")
  6044.     Resur #=    $    elf->{XMLERROR};")
  6045.     Resur #=~ s/\%s/InupniprpLoop \(\?\)/ und.
  6046.         }
  6047.     $Resur =un    t}h2
  6048.  URL
  6049. T    sume tw    # ifm
  6050. #0tolei-lS neelL
  6051. To ch fg tw    a u thi        #what!! Tnotpi    cept(d/proritsrvenvafg tr w##t# ergul             x\ct  per below -le reen aoact ur s-ere his ibelowESso##t# ifpbracke s-ere adoon/removeo,a                esureen aoaf
  6052.    #tolecodavg tsfit  sixe$.h2
  6053.  URLmTRle         rsT
  6054.         ss~ /  mem      (e                                    Sf thdoag lse                            ($1R mem    r<  mem    n\s*                                    Po  pfiluwhIteusp' i atpath a gin  soite.")taId                                    Ia< aifi_W)
  6055.  
  6056.         ([0-9a-zA-Z_]+?)se)        Tag    ed fi    lse                            ($2)(his R mem    r(e                                    Oe bstahwhidden partiona                        ($3)(his R mem    r (\s+                                    Pidden parif tharactersp' i                    ($4R mem    r  [0-9a-zA-Z_]+?                    Pidden pared fUCCES      (\=                                    Pidden par fielurifieequahwsign            ($5)de Name(                                    Pidden par fielse                            ($6)de Name (\"[^\"]+\") |                Pidden par fieluinedoubLE qu tes             ($7)de Name (\'[^\']+\') |                Pidden par fieluinesionLE qu tes             ($8)de Name ([^\"\'\ \/\>]+)                Pidden par fielurifi Errqu tes             ($9)de Name)    UCCES      )*?                                    Vfielu thoe bstahw(de our   th'SET'64 CES     )*?                                    Pidden passtre oe bstah4 CES    )  mem    n\s*                                    Po  pfiluwhIteusp' i mem    r(\/*?)                                Oe bstahwEnotserk e                            ($10)(his R mem    r\s*                                    Po  pfiluwhIteusp' i atpath eno mem        > mem      ) mem      | (<!--.*?-->)last# Or iamm< aslse                            ($11)(his R mem      /sx )  memr})
  6057. $sT
  6058.         s ny     ll            TMODE)nam  tth arfst  poinh r")
  6059.     Resur #.nC$`l            TMODEadore surrlnhwhidn e__)
  6060.         {
  6061.         Camm< a d-ly t!! Tnotpproritsrv    {
  6062.         Usupotenge thjsworsll she ha. Buts-le reen aoaifph filerarhll wsid  efstctsfitm#ir woret!seynmd theeaebet!ssse ef you iamm< as ErrXML tagsfitm#iTo ch fg tn aoa-msi        ty iamm< as Erriamm< asdseectper lss ractererg    x\Deb# lfitm#})
  6063. ;
  6064. ( $11 R                                        f  amm< as-Tpa# set# ume  mem    S)
  6065.             Resur #.nC$&;                            Add  amm< a-dlldthdanotalnhineld va    ry t; ##    tt}##
  6066.     ##        }
  6067. $sTag                    =     2;                    tagded fUC        }
  6068. $sPidden paT
  6069.             =     3;                    hidden partionUC        }
  6070. $sInsid T
  6071.                 Bn""er =#at
  6072.             betwee# if thdanot< $f(:mptyeessanow)UC        }
  6073. $sSf thTag            nC$&;            #aiampleteusf thdoagng        }
  6074. $sEnoTag;                                    iampleteu< $foag (e dh sosyet)UC        }
  6075. $Pidden paHash;                            hase w mhidden pas (e dh sosyet)UC__)
  6076.         {
  6077.         I                # if    modhidden pas                 eaehaseloCm#})
  6078. ;
  6079. ( $sPidden paT
  6080.          SUCCESS ##    tt$Pidden paHash#=    $    elf->P
  6081. #0 Pidden pas($sPidden paT
  6082.         ) und.");
  6083.     __)
  6084.         {
  6085.         I        notp'abbrevipprvesyntax'aoesn'f0 t< $-tagloCm#})
  6086. ;
  6087. ( !$10#) {
  6088. $sInsid T
  6089.          #=    $    elf->FinoEnoTag(taId,$sTag,\$sT
  6090.         ,\$sEnoTag); );
  6091.     __)
  6092.         {
  6093.         I        tagdh filernin DEFAULT SERis r,  whiuit,wo                wi@Rejswor        {
  6094.         lhluwhol -ly tch
  6095.         Inped b     0 ,    m
  6096. #0 -lerat
  6097.             LicuN pvely
  6098.  
  6099.         ng        }
  6100. $sG n colTagd= uc($sTag);})
  6101. ;
  6102. ( !SERis r(        elf->{Tags}->{$sG n colTag})#) {
  6103. $sG n colTagd= 'DEFAULT' }####        ;
  6104. ( SERis r(        elf->{Tags}->{$sG n colTag})#)se)        Tagdh filernse no memSS ##    tt#)
  6105.         # C lhwdagdh filernernam
  6106. #0     ly the aoaior        {
  6107.     sacc        #)
  6108.         }
  6109. $sRr\w' i =    &{        elf->{Tags}->{$sG n colTag}}(de Name
  6110.  
  6111.  
  6112.  
  6113.  
  6114.  
  6115.  
  6116.  
  6117.  
  6118.  
  6119.  
  6120.  
  6121.  
  6122.  
  6123. $sTag,                            Tagded fUC        ame
  6124.  
  6125.  
  6126.  
  6127.  
  6128.  
  6129.  
  6130.  
  6131.  
  6132.  
  6133.  
  6134.  
  6135.  
  6136.  
  6137. \$sInsid T
  6138.         ,                Rist - referer
  6139.             betwee# oagsde Name
  6140.  
  6141.  
  6142.  
  6143.  
  6144.  
  6145.  
  6146.  
  6147.  
  6148.  
  6149.  
  6150.  
  6151.  
  6152.  
  6153. $Pidden paHash,                Rist - referehase w mhidden pasde Name
  6154.  
  6155.  
  6156.  
  6157.  
  6158.  
  6159.  
  6160.  
  6161.  
  6162.  
  6163.  
  6164.  
  6165.  
  6166.  
  6167. $sId,last;##Cur - otPresixde Name
  6168.  
  6169.  
  6170.  
  6171.  
  6172.  
  6173.  
  6174.  
  6175.  
  6176.  
  6177.  
  6178.  
  6179.  
  6180.  
  6181. $sSf thTag            # Fuoter
  6182.             w mif thdoagng Name
  6183.  
  6184.  
  6185.  
  6186.  
  6187.  
  6188.  
  6189.  
  6190.  
  6191.  
  6192.  
  6193.  
  6194.  
  6195.  )th2h2(
  6196.  
  6197. ;
  6198. ( $sRr\w' i eq
  6199. $sSf thTag R                                    Trned navoi iinupniprpoespsde Nam{    
  6200.     else                                    I        noth sosch fg r,lS n'tam
  6201. #0     ag\" ite.")tResur #.nC$sRr\w' isite.");
  6202.                     }} mem    re
  6203.                     Resur #.nC$    elf->P
  6204. #0 ($sRr\w' i,$sId)site.");
  6205.             #)
  6206.         # 
  6207. #0 -l
  6208.             betwee# if th-tagdanot< $-tagd va    #)
  6209.         $Resur #.nC$    elf->P
  6210. #0 ($sInsid T
  6211.         ,$sId)site."h2(
  6212.  
  6213. ;
  6214. ( SERis r(        elf->{Tags}->{$sG n colTag.'_END'})#)s#eE $-tagd-  whiuh filernernam
  6215. #0             {
  6216.      d-ly tchem    re
  6217.                     sRr\w' i = &{        elf->{Tags}->{$sG n colTag.'_END'}}('/'.$sTag,n"",n"",n$sId, $sEnoTag);ite.");
  6218.                     }}
  6219.     else                            
  6220.         # De our   oelocas$sFinsmif thdoagng Name
  6221.                     sRr\w' i = &{        elf->{Tags}->{$sG n colTag}}('/'.$sTag,n"",n"",n$sId, $sEnoTag);ite.");
  6222. h2(
  6223.  
  6224. ;
  6225. ( $sRr\w' i eq
  6226. $sEnoTag )last;                # Trned navoi iinupniprpoespsde Nam{    
  6227.     else                                            I        noth sosch fg r,lS n'tam
  6228. #0     ag\" ite.")tResur #.nC$sRr\w' isite.");
  6229.                     }} mem    re
  6230.                     Resur #.nC$    elf->P
  6231. #0 ($sRr\w' i,$sId)site.");
  6232.             }##
  6233.             }e    else                                    Nouh filernernano!de our ,ejsworp
  6234. #0 -l
  6235.             betwee# oagsde Na{    )
  6236.         $Resur #.nC$sSf thTag .C$    elf->P
  6237. #0 ($sInsid T
  6238.         ,$sId)ule.
  6239. EnoTag;
  6240.             ng
  6241.             }
  6242.         }
  6243.  $Resur #. $sT
  6244.                 #
  6245. yp < $# lhwd wireonal lly t!!        no!ssse oagsde ef)
  6246.  
  6247. ########################################################### 
  6248. PXML->FinoEnoTag()a- sinote $-tagsagee
  6249. Avalid as:  a $sIri-rcur - otID##i aaaaaaaaaaaaa  
  6250. $sTag -wtagded fUC# aaaaaaaaaaaaa  
  6251. \$sT
  6252.          -wList - referer
  6253.             eoaoesn'y - B aaaaaaaaaaaaa  
  6254. \$sEnotldList - refere< $foag (pnipiaty :mpty)sagee rsT
  6255.         s! T    h fg ris_);
  6256.  thda parttriee $-tagsagee
  6257.  
  6258. #
  6259. # Rer
  6260.             fe notbefsse loiee $-tagsagnge aRysze stZyb No  Nov 28 14:42:23 GMT 1999messageeCopyright (c)                        # ASoftwl        #Ltd 1999mes##
  6261.  
  6262. #####################################################as#####
  6263. FinoEnoTagurePath
  6264.     {Self#s $nam =unt}
  6265. ($sId, $sTag,n$sT
  6266.         ,e.
  6267. Enoassword) =__);
  6268. ( $EsT
  6269.         ss~ / < \s* \/ $sIri$sTag \s* > /sx )        #
  6270. Lesn'f0 t< $-tagloCmr})
  6271. $$sT
  6272.         ss     ll            TM# T
  6273.             t part< $foagng
  6274. $$sEnot nC$&;                            T
  6275.             w m< $foagng
  6276.  
  6277.         }
  6278.  $`l            TMODET
  6279.             betwee# if th-tagdanot< $-tagd va        }
  6280.         }
  6281.     else                Netese notldLit
  6282. # :  0 -ttinanch fg r-ly tchemr})
  6283. }
  6284. $eErr#=    $    elf->{XMLERROR};")
  6285.     eErr#s ny~ s/\%s/$sIr$sTag/ und.
  6286.         }
  6287.     $eErr#. $EsT
  6288.         ;##    t}h2t 0)
  6289.  
  6290. ########################################################### 
  6291. PXML->P
  6292. #0 Pidden pas() -    m
  6293. #0 -hidden partionUCr aSslitswhidden partionaanotsekeseaehaseloOtusagee
  6294. Avalid as:    pidden parif the (mswors
  6295.  thdrifiewhIteusp' i)sagee
  6296.  
  6297. #
  6298. # R    hidden parhasedList - resagnge aRysze stZyb No  Nov 30 10:47:24 GMT 1999messageeCopyright (c)                        # ASoftwl        #Ltd 1999mes##
  6299.  
  6300. #####################################################as#####
  6301. P
  6302. #0 Pidden pasde ath2
  6303.     $Self#s
  6304. #  ss $nam =unt}
  6305. $sPidden passsw$nam =untath
  6306.     {Pidden paHash#=        ) und    }
  6307.  URL
  6308. IMPORTANT:URL
  6309.  
  6310. #den parif the if tharIMMEDIATELY    t partercognised TAGURL
  6311. So:aiorMUSTrs
  6312.  thdacterwhIteusp' i me URLmTRle         rsPidden passs~ m/\G  mem      \s+                            t# Obligat0 y!whIteusp' i mem      ([0-9a-zA-Z_]+)                        Pidden pared f ($1R mem      (\= mem    r(e mem    r (\"[^\"]+\") |                    Pidden par fieluinedoubLE qu tes mem    r (\'[^\']+\') |                    Pidden par fieluinesionLE qu tes mem    r ([^\"\'\ \/\>]+)                    Pidden par fielurifi Errqu tes4 CES    )                                        Pidden par fielu($3) mem      )*                                        '= fiel' meynmetebe         # if($2) mem      /gsx )chemr})
  6313. }
  6314. $eN$sFssw$1;})
  6315. ;
  6316. ( $2 )                                        T    # if thi  field va    {)
  6317.         }
  6318. $s ("\"ssw$3;)
  6319.         $s ("\"ss~ s/^(\"|\')//;            Rimove              tolequ te)
  6320.         $s ("\"ss~ s/(\"|\')$//;            Rimove tr\"ltolequ te)
  6321.         $Pidden paHash->{$sN$sF}$nC$sVhy (site        }##
  6322.             }e    else                        Nou fiel,h#etpitpao 'SET' mem    S)
  6323.             Pidden paHash->{$sN$sF}$nC'SET';
  6324.             ng
  6325.             }
  6326.         }
  6327.  $Pidden paHash;iteef)f)
  6328.  
  6329. ########################################################### 
  6330. ick($s    yle = $_PXML - yle = $eIf the c    m
  6331. #0 r t# 
  6332. T    sume tapprotype'f0 tdevelopid a###sageeRysze stZyb No  Dec  7 20:52:23 GMT 1999messageeCopyright (c)                        # ASoftwl        #Ltd (1999)#####
  6333.  
  6334. #####################################################as##
  6335. ick($s    yle = $_PXMLFIL#u{
  6336. alur    iut V N per => "1.0, (PXML: "ulePXML->V N per . ")"th2;
  6337. rCe!v
  6338. #0 qw(@ISA) un@ISA$nCqw(PXML)th2h2###
  6339.  - turePath
  6340.     {Proto s $nam =unt}
  6341. $Clorrny ref({Proto) ||    {Proto=unt}
  6342. $self#ss $Clorr->SUPER:: - ();    else                                            dlnhwhissinvalid as,            #caexatasSei()und    }
  6343. files    
  6344. self,
  6345. $Clorrath2(h2(    self->Sei(UCCES      ID                        =>    '                    # :',else                                            de our  presixde Nam  MAINFRAME                =>    ###
  6346. {     self->M\" Fc$sFTagH filer(@__
  6347.         ,                hafileuurliof  (orllc$sFde Nam  PRICES                    => ###
  6348. {     self->PricFTagH filer(@__
  6349.     
  6350.         ,                pricFdoagng NameeRETAIL_PRICE_TEXT    =>    ###
  6351. {     self->Rse\"lPricFT
  6352.         TagH filer(@__    ,                rse\"l    pricFdo
  6353.             eagng NameeVAR                        => ###
  6354. {     self->VarTagH filer(@__
  6355.     
  6356.         ,                v
  6357. #    eagng NameeSE{
  6358. ON                => ###
  6359. {     self->SectperTagH filer(@__
  6360.     
  6361.     ,                sectper eagng NameeADDR#
  6362. ES                => ###
  6363. {     self->AddrtusTagH filer(@__
  6364.     
  6365.     ,                 ddrtuses eagng NameeUNREG                    => ###
  6366. {     self->UnregTagH filer(@__
  6367.     
  6368.         ,                unergioners iatalheagng NameeIGNORE                    => ###
  6369. {     self->IgnsseTagH filer(@__
  6370.     
  6371.     ,                IGNOREfoag (deletesat
  6372.         R mem    r  NOe =B2B                => ###
  6373. {     self->NetInB2BTagH filer(@__
  6374.     
  6375.     ,                NOe =B2Bfoag (deletesat
  6376.         R mem    r  DEFAULT                => ###
  6377. {     self->De our TagH filer(@__
  6378.     
  6379.     ,                ankmewn oagscthripSho    r  XMLERROR                => "<br><flnhwsize=+2
  6380. allor=rs ><b>". yle = $ACGetshr    0 (-1, 218)M.    "</b></flnh><br>",4 CES     );h2(    self->Sei(@__FIL.
  6381.         }
  6382.     $eelf;;
  6383. ef)
  6384.  
  6385. ########################################################### 
  6386. AddrtusTagH filerd-  whibick'f0 t ddrtusesUC#tu
  6387. \w' is <                    # :ADDR#
  6388. ES/>foag by  ddrtusfoafil### 
  6389. ### 
  6390. Avalid asn:     sTag -wtagded fUC# aaaaaaaaaaaaa$sInsid T
  6391.          -wList - referer
  6392.             betwee# if thdanot< $,UC# aaaaaaaaaaaaa$Pidden paHash#-ehase w mhidden pas,UC# aaaaaaaaaaaaa$sIri-rcur - ottagdpresix,UC# aaaaaaaaaaaaa$sFuotTag -wfuoter
  6393.             w mcur - ottag;UC#tu
  6394. #
  6395. # aaa:  ddrtusfoafil###sageeRysze stZyb No  Jaex 3 16:44:37 GMT 2000messageeCopyright (c)                        # ASoftwl        #Ltd (2000)#####
  6396.  
  6397. #####################################################as#####
  6398. yddrtusTagH filerurePath
  6399.     {Self#s $nam =unt}
  6400. ($sTag,na$sInsid T
  6401.         ,
  6402. $Pidden paHash,n$sId, $sFuotTagassword) = @_$sDigess BStyle = $ACB2B->Get('wordDigess'ath2    }
  6403. ;
  6404. (     sTag !~ /^\// )last;                se                                            Ignsset< $-tage tgry")
  6405. ;
  6406.     
  6407. Samy ($Stsatus, $, EpBry_Wasswyle = $ACGetBry_W($sDigess,wyle = $ACGetsub (<",wn t
  6408.         
  6409.         if ($Siel, 2)###
  6410. R mem    S)
  6411.         
  6412.         }
  6413.     r"");;
  6414.         ng
  6415.     }
  6416. $pAy the sErro    
  6417. Samy ($Stsatus, $, EpAy the asswyle = $ACGetCuuesmerAy the     retBry_W{Ay the ID},wyle = $ACGetsub (<",wn t
  6418.         
  6419.         if ($Siel, 2)###
  6420. R mem    S)
  6421.         
  6422.         }
  6423.     r"");;
  6424.         ng
  6425.     }
  6426. @AddrtusId\@Fi#s $slit(/,/, $EpAy the {Addrtus\@Fi}nst,  ;
  6427. $AddrtusIDst,  ;
  6428. %Addrtus\@Fist,  esse tha$AddrtusID (@AddrtusId\@Fi)
  6429.             S)
  6430.         {
  6431. Samy ($Stsatus, $, EAddrtus\@Fi{$AddrtusID}asswyle = $ACGetCuuesmerAddrtus(    etBry_W{Ay the ID},w$AddrtusID, yle = $ACGetsub (<",wn tr
  6432.         
  6433.         if ($Siel, 2)###
  6434. R mem    re
  6435.                     {
  6436.         $AC
  6437.  
  6438.     {
  6439. CuuesmerAddrtusISSEx(", 0,TbuisuuesmeriSea<xme tleft nlesslenamulti    to awritsESso                 nmet!up thripSho        
  6440.         }
  6441.     r"");;
  6442.         );
  6443.             }##g
  6444.     }
  6445. @Tempsswkeys %Addrtus\@Fist,  
  6446.         
  6447. #Tempss= -1SUCCE    S)
  6448.             {
  6449.         $AC
  6450.  
  6451.     {
  6452. CuuesmerAddrtusISSEx(",                T    #isuuesmeriSea<xme tleft nlesslenamulti    to awritsESso                 nmet!up thripSho    
  6453.         }
  6454.     r"");;
  6455.         ng
  6456. ")
  6457. ;
  6458.     
  6459. sType,$sSelect,$nRtil,$sCcecked);})
  6460. ;
  6461. (     Pidden paHash->{TYP:}i=~ /^INVOICE/ )last;                se        Invoice fddrtusfitrch?
  6462.             sType  ss 'VhyidAsInvoiceAddrtus';        se                                            T    sum                 eedtestedeessae thafddrtusfitrc;
  6463. (     pAy the ->{InvoiceAddrtusRtil}Wn= 1 )last;                s        T    #iCuuesmerirtil overrid thary_Wirtil mem    re
  6464.                     nRtilny 0th2(
  6465.             sSelectV=     pAy the ->{InvoiceAddrtus}F                               # De our  (0 -FIx r)efddrtusfitrc    {
  6466. Samy ($Stsatus, $, EAddrtus\@Fi{$sSelect}asswyle = $ACGetCuuesmerAddrtus(    etBry_W{Ay the ID},w$sSelect, yle = $ACGetsub (<",wn trr
  6467.         
  6468.         if ($Siel, 2)###
  6469. Re mem    rre
  6470.                         {
  6471.         $AC
  6472.  
  6473.     {
  6474. CuuesmerAddrtusISSEx(", 0,TbuisuuesmeriSea<xme tleft nlesslenamulti    to awritsESso                 nmet!up thripSho            
  6475.         }
  6476.     r"");;
  6477.         ));
  6478.             );
  6479.                     }} mem    re
  6480.                     nRtiln V=     pBry_W->{InvoiceAddrtusRtil};lse                                    Addrtusfrtil essage thatal mem            sSelectV=     pBry_W->{InvoiceAddrtusID};                              # De our  (0 -FIx r)efddrtusfitrc    }##    tt}##
  6481.             }
  6482. (     Pidden paHash->{TYP:}i=~ /^DELIVERY/ )last;                s        Deli loy  ddrtusfitmch?
  6483.             sType  ss 'VhyidAsDeli loyAddrtus';        se                                        T    sum                 eedtestedeessae thafddrtusfitrc    nRtiln V=     pBry_W->{Deli loyAddrtusRtil};lse                                    Addrtusfrtil essage thatal mem        sSelectV=     pBry_W->{Deli loyAddrtusID};e                            
  6484.         # De our  (0 -FIx r)efddrtusfitrc}})
  6485. ;
  6486. (     Pidden paHash->{TYP:}i=~ /FORM$/ )last;                se            Addrtusfstrifitmch?
  6487.         ;
  6488. (     nRtiln!BS2 )last;                se                                # O surshewn essaRtiln2 mem    re
  6489.                     $sInsid T
  6490.          Bn""efitrc    }##    tt    {
  6491.         $AC
  6492.  
  6493.     {
  6494. CuuesmerAddrtusISSEx(",                T    #isuuesmeriSea<xme tleft nlesslenamulti    to awritsESso                 nmet!up thripSho    
  6495.         }
  6496.     ""efitrcng
  6497. ")
  6498.     {
  6499.         $AC
  6500.  
  6501.     {
  6502. CuuesmerAddrtusISSEx(",                T    #isuuesmeriSea<xme tleft nlesslenamulti    to awritsESso                 nmet!up thripS__)
  6503.         {
  6504.         Ftring 'm        #  amelaeas'.fitm#iT filut tlnDeu"Inddrtusfstriaasds < $#on     nRtil,         # ifmsworeedk liessae thartil mem###        }
  6505. $sTafilFtring  n    =         elf->{Vh t file}->{ADDR#
  6506. _TABLE};##        }
  6507. $sT tln             =         elf->{Vh t file}->{'ADDR#
  6508. _TITLE'#. $nRtil};##        }
  6509. $sT tln_1            =         elf->{Vh t file}->{'ADDR#
  6510. _TITLE1'#. $nRtil};##        }
  6511. $sFtri                = '<TD>' .C$    elf->{Vh t file}->{'ADDR#
  6512. _FORM'#. $nRtil}#. '</TD>';de
  6513.         {
  6514.         Nurns:    w mcolumnsre surmd thes!!        ioact ur s-in!ssse oh    nmk lirow    {
  6515.         O                wi@Reacter sos ddrtuses                  expanotaoile latocatabil mem###        }
  6516. $nColumnsr#s
  6517. #  ss         elf->{Vh t file}->{ADDR#
  6518. _COLUMNS} ||    1;            #aNurns:    w mcolumnsr-    de our   o 1####        ;
  6519. ( !$sFtrinin !$sTafilFtring )  mem    S ##    tt
  6520.         }
  6521.     ""efitrcn lse                                    Noustriaasr-            #caemeterohe ao##
  6522.     ##        }
  6523. $syddrtusT
  6524.          Bn""efitr})
  6525. ;
  6526. (     nRtilny= 0 )last;                    se                                # Rtiln0a- sixed  ddrtusfitmch?
  6527.             syddrtusT
  6528.          .= '<TR><TD>';        se                                            # JsworaesionLE cell##    t        syddrtusT
  6529.          .= smRL =f($sFtri,de Name
  6530.  
  6531.  
  6532.  
  6533.  
  6534.  
  6535. w$sSelect,    last;                se            AddrtusfID##tName
  6536.  
  6537.  
  6538.  
  6539.  
  6540.  
  6541. w$Addrtus\@Fi{$sSelect}->{N$sF},        se            Addrtusfr
  6542.             fehi #s##tName
  6543.  
  6544.  
  6545.  
  6546.  
  6547.  
  6548. w$Addrtus\@Fi{$sSelect}->{Lss 1},##tName
  6549.  
  6550.  
  6551.  
  6552.  
  6553.  
  6554. w$Addrtus\@Fi{$sSelect}->{Lss 2},##tName
  6555.  
  6556.  
  6557.  
  6558.  
  6559.  
  6560. w$Addrtus\@Fi{$sSelect}->{Lss 3},##tName
  6561.  
  6562.  
  6563.  
  6564.  
  6565.  
  6566. w$Addrtus\@Fi{$sSelect}->{Lss 4},##tName
  6567.  
  6568.  
  6569.  
  6570.  
  6571.  
  6572. w$Addrtus\@Fi{$sSelect}->{PostCode},##tName
  6573.  
  6574.  
  6575.  
  6576.  
  6577.  
  6578. w    {
  6579.         $ACGetCthe ryN$sF(
  6580. Addrtus\@Fi{$sSelect}->{Cthe ryCode}));?
  6581.             syddrtusT
  6582.          .= '</TD></TR>';##    tt}##
  6583.             }e    else                                    se                                # Rtiln1 #    s    lectVactertionUC        m{    
  6584.     else                                                                # Rtiln2 #    s    lectV0 -FIlhwftrifitmc$sT tln = smRL =f($sT tln,yle = $ACGetshr    0 (-1, 302));                se        Ins No t tlnDacterhctepts?
  6585.         ;
  6586. (     nRtiln=BS2 )last;                se                                # Ins No t
  6587.             ferInddrtusfstri mem    re
  6588.                 ;
  6589. (     Pidden paHash->{TYP:}i=~ /^INVOICE/ ) mem    rre
  6590.                     $sT tln_1 = smRL =f($sT tln_1,yle = $ACGetshr    0 (-1, 303,yle = $ACGetshr    0 (-1, 304)));;
  6591.         ));
  6592.             )        }} mem    rre
  6593.                     $sT tln_1 = smRL =f($sT tln_1,yle = $ACGetshr    0 (-1, 303,yle = $ACGetshr    0 (-1, 305)));;
  6594.         ));
  6595.             )})
  6596.         }
  6597. $nCthe i= 0th2(
  6598.     }
  6599. $nRowCthe i= 0th2(
  6600.     }
  6601. $sCcth2(
  6602.     esse tha(keys %Addrtus\@Fi) mem    re
  6603.                 ;
  6604. (     Addrtus\@Fi{$_}->{$sType} ) mem    rre
  6605.                     ;
  6606. (     nCthe i%
  6607. $nColumnsry= 0 )##tName
  6608. e
  6609.                             syddrtusT
  6610.          .= '<TR>';        se                                            Newirow    {
  6611.         ));
  6612.             )    ;
  6613. (     _ eq
  6614. $sS    lectVanot    nRtiln=BS1 )last;                s        FssaRtiln1 cceck    de our  fddrtusfitrc    e
  6615. e
  6616.                             sCh#=    ' CHECKED';    {
  6617.         ));
  6618.             )            }} mem    rr
  6619. e
  6620.                             sCh#=    '';    {
  6621.         ));
  6622.  
  6623.                     $syddrtusT
  6624.          .= smRL =f($sFtri,de Name
  6625.  
  6626.  
  6627.  
  6628.  
  6629.  
  6630.  
  6631.  
  6632. w    {
  6633.         $ACGetshr    0 (-1, 301),de Name
  6634.  
  6635.  
  6636.  
  6637.  
  6638.  
  6639.  
  6640.  
  6641. w$_,    last;                se            AddrtusfID (essaRADIOacteton)de Name
  6642.  
  6643.  
  6644.  
  6645.  
  6646.  
  6647.  
  6648.  
  6649. w$sCh,        se                                # Oe bstahw'CHECKED'de Name
  6650.  
  6651.  
  6652.  
  6653.  
  6654.  
  6655.  
  6656.  
  6657. w$Addrtus\@Fi{$_}->{N$sF},        se            Addrtusfr
  6658.             fehi #s##tName
  6659.  
  6660.  
  6661.  
  6662.  
  6663.  
  6664.  
  6665.  
  6666. w$Addrtus\@Fi{$_}->{Lss 1},##tName
  6667.  
  6668.  
  6669.  
  6670.  
  6671.  
  6672.  
  6673.  
  6674. w$Addrtus\@Fi{$_}->{Lss 2},##tName
  6675.  
  6676.  
  6677.  
  6678.  
  6679.  
  6680.  
  6681.  
  6682. w$Addrtus\@Fi{$_}->{Lss 3},##tName
  6683.  
  6684.  
  6685.  
  6686.  
  6687.  
  6688.  
  6689.  
  6690. w$Addrtus\@Fi{$_}->{Lss 4},##tName
  6691.  
  6692.  
  6693.  
  6694.  
  6695.  
  6696.  
  6697.  
  6698. w$Addrtus\@Fi{$_}->{PostCode},##tName
  6699.  
  6700.  
  6701.  
  6702.  
  6703.  
  6704.  
  6705.  
  6706. w    {
  6707.         $ACGetCthe ryN$sF(
  6708. Addrtus\@Fi{$_}->{Cthe ryCode}));?
  6709.             e mem    rr    nCthe ++;last;                se                                # Cthe icells
  6710.                     ;
  6711. (     nCthe i%
  6712. $nColumnsry= 0 )        se                                # Fuoterow    {
  6713.         ))e
  6714.                             syddrtusT
  6715.          .= '</TR>';        se                                            
  6716.  
  6717.     {
  6718. erow    {
  6719.         ))$nRowCthe ++;last;                se                        # Cthe ir #s##tName
  6720. };
  6721.         ));
  6722.             )})
  6723.  
  6724.             mTRle(     nCthe i%
  6725. $nColumnsr!= 0 )last;                    se            
  6726.  
  6727.     {
  6728. etabilir #ree
  6729. metec
  6730.     {
  6731. d mem    re
  6732.                 ;
  6733. (     nRowCthe i> 0#) {
  6734. $syddrtusT
  6735.          .= '<TD> </TD>' }                        If!ssse oh    nmk lirowt:    fdd :mptyicells
  6736.                     nCthe ++;
  6737.                 ;
  6738. (     nCthe i%
  6739. $nColumnsry= 0 )##tName{
  6740.                     $syddrtusT
  6741.          .= '</TR>';##    tt        laFist,      ));
  6742.             )})
  6743.         );
  6744.     EsyddrtusT
  6745.          B~ s/<br>[,\s]*/<br>/gi;        se                                            Rimove              tole ammas;
  6746.     EsyddrtusT
  6747.          B~ s/[,\s]*<br>/<br>/gi;        se                                            Rimove tr\"ltole ammas;
  6748.     
  6749.         }
  6750.     smRL =f($sTafilFtring,##tName
  6751.  
  6752. $sT tln,##tName
  6753.  
  6754. $    tu
  6755.     pSetup            
  6756. {FORM_EMPHASI
  6757. _COLOR},                                     Bo sam##tName
  6758.  
  6759. $    tu
  6760.     pSetup            
  6761. {FORM_BACKGROUND_COLOR},                                     Backgre no memS                $syddrtusT
  6762.         ,##tName
  6763.  
  6764. $sT tln_1ns##    t}h2
  6765.         }
  6766.     ""efit})
  6767.  
  6768. f)
  6769.  
  6770. ########################################################### 
  6771. ###
  6772. VarTagH filerd-  whibick'f0 tth t file t# #Se s-th t file t# #Te# ifshouldneedAR:UVanotVALUEchidden pas t#          elf->{Vh t file}->{n$sF}$ th#etpao  field #tusageeAvalid asn:     sTag -wtagded fUC# aaaaaaaaaaaa$sInsid T
  6773.          -wList - referer
  6774.             betwee# if thdanot< $,UC# aaaaaaaaaaaa$Pidden paHash#-ehase w mhidden pas,UC# aaaaaaaaaaaa$sIri-rcur - ottagdpresix,UC# aaaaaaaaaaaa$sFuotTag -wfuoter
  6775.             w mcur - ottag;UC#tu
  6776. #
  6777. # aaa: :mptyiif the###sageeRysze stZyb No  Dec  7 20:58:25 GMT 1999messageeCopyright (c)                        # ASoftwl        #Ltd (1999)#####
  6778.  
  6779. #####################################################as#####
  6780. VarTagH filerurePath
  6781.     {Self#s $nam =unt}
  6782. ($sTag,na$sInsid T
  6783.         ,
  6784. $Pidden paHash,n$sId, $sFuotTagassword)     }
  6785. ;
  6786. (     sTag !~ /^\// )loCmr})
  6787. $    elf->{Vh t file}->{    Pidden paHash->{AR:U}}$nC$Pidden paHash->{VALUE}s##    t}h2
  6788.         }
  6789.     ""efit})
  6790.  
  6791.  
  6792. ########################################################### 
  6793. ###
  6794. De our TagH filerd-  whibick'f0 tankmewn oags### 
  6795. Lesnsmup tth tagd!        lhluB2B    XML    TageDhaseloOtuIf!se notldLi\w' is tth tagdby inUCr a(meanthe shluwhol -<                    # :    sTag....>h#equ- re)sageeIftmetemodun'ta-            l she loyth soshe ouccedd #tusageeAvalid asn:     sTag -wtagded fUC# aaaaaaaaaaaa$sInsid T
  6796.          -wList - referer
  6797.             betwee# if thdanot< $,UC# aaaaaaaaaaaa$Pidden paHash#-ehase w mhidden pas,UC# aaaaaaaaaaaa$sIri-rcur - ottagdpresix,UC# aaaaaaaaaaaa$sFuotTag -wfuoter
  6798.             w mcur - ottag;UC#tu
  6799. #
  6800. # aaa: Li\w' im< asFenage foagngesageeRysze stZyb No  Dec  7 20:58:25 GMT 1999messageeCopyright (c)                        # ASoftwl        #Ltd (1999)#####
  6801.  
  6802. #####################################################as#####
  6803. De our TagH filerurePath
  6804.     {Self#s $nam =unt}
  6805. ($sTag,na$sInsid T
  6806.         ,
  6807. $Pidden paHash,n$sId, $sFuotTagassword) = @_$sXMLTagd= tyle = $ACB2B->GetXML($sTag);})
  6808.         }
  6809.     rSERis r(    sXMLTag)) ?i$sXMLTagd: $sFuotTag;    iteef)f)
  6810.  
  6811. ############################################################## 
  6812. ###
  6813. Rse\"lPricFT
  6814.         TagH filerd-  whibick'f0 trse\"l    ly tchOtuSe s-XML    th t fil### 
  6815. B2B->{XML}->{oag}$ th#etpao  fielal lly t!betwee# oagsde#tusageeAvalid asn:     sTag -wtagded fUC# aaaaaaaaaaaa$sInsid T
  6816.          -wList - referer
  6817.             betwee# if thdanot< $,UC# aaaaaaaaaaaa$Pidden paHash#-ehase w mhidden pas,UC# aaaaaaaaaaaa$sIri-rcur - ottagdpresix,UC# aaaaaaaaaaaa$sFuotTag -wfuoter
  6818.             w mcur - ottag;UC#tu
  6819. #
  6820. # aaa: :mptyiif the###sag##
  6821.  
  6822. #####################################################as#######
  6823. Rse\"lPricFT
  6824.         TagH filerurePath
  6825.     {Self#s $nam =unt}
  6826. ($sTag,na$sInsid T
  6827.         ,
  6828. $Pidden paHash,n$sId, $sFuotTagassword)     }
  6829. ;
  6830. (     sTag !~ /^\// )se                                            Ignsset< $-tag    iampletely
  6831.  
  6832. --)
  6833.         {ref({sInsid T
  6834.         ))                                            I                # if thr
  6835.             ;
  6836. sse et!!n-XML    th t fil##tmch?
  6837.                 {
  6838.         $ACB2B->SetXML($sTag,n${sInsid T
  6839.         );?
  6840.             $sInsid T
  6841.          Bn""ee                                        T
  6842.          meteneededderyssse
  6843.             ng
  6844.             }
  6845.         }
  6846.  ""ee                                                            BofielageDels_)removeoiteef)f)
  6847.  
  6848. ########################################################### 
  6849. De our RimovtheTagH filerd-  whibick'f0 tankmewn oags### 
  6850. As
  6851. De our TagH filerdexcepthe aoaankmewn oagsctre removeoiti atoge        # drifieaoter
  6852.             betwee# oagsde#### 
  6853. Lesnsmup tth tagd!        lhluB2B    XML    TageDhaseloOtuIf!se notldLi\w' is tth tagdby inUCr a(meanthe shluwhol -<                    # :    sTag....>h#equ- re)sageeIftmeteremoveshe loyth so### 
  6854. ### 
  6855. Avalid asn:     sTag -wtagded fUC# aaaaaaaaaaaaa$sInsid T
  6856.          -wList - referer
  6857.             betwee# if thdanot< $,UC# aaaaaaaaaaaaa$Pidden paHash#-ehase w mhidden pas,UC# aaaaaaaaaaaaa$sIri-rcur - ottagdpresix,UC# aaaaaaaaaaaaa$sFuotTag -wfuoter
  6858.             w mcur - ottag;UC#tu
  6859. #
  6860. # aaa: Li\w' im< asFenage foagngesageeRysze stZyb No  Dec  7 20:58:25 GMT 1999messageeCopyright (c)                        # ASoftwl        #Ltd (1999)#####
  6861.  
  6862. #####################################################as#####
  6863. De our RimovtheTagH filerurePath
  6864.     {Self#s $nam =unt}
  6865. ($sTag,na$sInsid T
  6866.         ,
  6867. $Pidden paHash,n$sId, $sFuotTagassword) =) = @_$sXMLTagd= tyle = $ACB2B->GetXML($sTag);})
  6868. ;
  6869. ( SERis r(    sXMLTag)#)s#eD n'ta ouccer
  6870.         ,dLit
  6871. # Li\w' im< astagloCmr})
  6872.  
  6873.         }
  6874.     $eXMLTag;d va        }
  6875.         }
  6876.     else        e            
  6877.  
  6878.             #bofiel
  6879.             ttintagloCmr})
  6880.         {    ref({sInsid T
  6881.         )#) {
  6882. $$sInsid T
  6883.          Bn""e );
  6884.     
  6885.         }
  6886.     ""efitr}iteef)f)
  6887.  
  6888. ########################################################### 
  6889. IgnsseTagH filerUC#tu
  6890. move t
  6891.          rifi!        lhlutagdanotge foagngesageeRysze stZyb No  Jul 25 22:30:51 BST 2000messageeCopyright (c)                        # ASoftwl        #Ltd (2000)#####
  6892.  
  6893. #####################################################as#####
  6894. IgnsseTagH filerUCePath
  6895.     {Self#s $nam =unt}
  6896. ($sTag,na$sInsid T
  6897.         ,
  6898. $Pidden paHash,n$sId, $sFuotTagassword) =        {    ref({sInsid T
  6899.         )#) {
  6900. $$sInsid T
  6901.          Bn""e );
  6902.  
  6903.         }
  6904.     ""efit})
  6905.  
  6906.  
  6907.  
  6908. ########################################################### 
  6909. NetInB2BTagH filersageeIftloc if thi ergioners iatalhremoveshge foagsm< $fo
  6910.             betwee#UC# aaaAvalid asn:     sTag -wtagded fUC# aaaaaaaaaaaaaaa$sInsid T
  6911.          -wList - referer
  6912.             betwee# if thdanot< $,UC# aaaaaaaaaaaaaaa$Pidden paHash#-ehase w mhidden pas,UC# aaaaaaaaaaaaaaa$sIri-rcur - ottagdpresix,UC# aaaaaaaaaaaaaaa$sFuotTag -wfuoter
  6913.             w mcur - ottag;UC#tutu
  6914. #
  6915. # aaa: ""ngesageeRysze stZyb No  Jul 28 14:20:06 BST 2000messageeCopyright (c)                        # ASoftwl        #Ltd (2000)#####
  6916.  
  6917. #####################################################as#####
  6918. NetInB2BTagH filersaePath
  6919.     {Self#s $nam =unt}
  6920. ($sTag,na$sInsid T
  6921.         ,
  6922. $Pidden paHash,n$sId, $sFuotTagassword) =) =;
  6923. (     sTag !~ /^\// )last;                se                                    
  6924.         I        notpEtintagloCmr})
  6925.  @_$sDigess BStyle = $ACB2B->Get('wordDigess'ath2    
  6926. ;
  6927. ( $sDigess )                    I                # if thaiatalhremove oagsctnd-ly tchem    h?
  6928.         ;
  6929. ( ref({sInsid T
  6930.         )#) {
  6931. $$sInsid T
  6932.          Bn""e );
  6933.         ng
  6934.             }
  6935.         }
  6936.  ""efit})
  6937.  
  6938.  
  6939.  
  6940. ########################################################### 
  6941. UnregTagH filerd-  whibick'f0 tUNREGfoagnge aIftloc if thi ergioners iatalhremoveshge foagsm< $fo
  6942.             betwee#UC# aO                wi@Reproduceseaewl    nthe p($s    tnd-be n is toaoegin p($smessageeAvalid asn:     sTag -wtagded fUC# aaaaaaaaaaaaa$sInsid T
  6943.          -wList - referer
  6944.             betwee# if thdanot< $,UC# aaaaaaaaaaaaa$Pidden paHash#-ehase w mhidden pas,UC# aaaaaaaaaaaaa$sIri-rcur - ottagdpresix,UC# aaaaaaaaaaaaa$sFuotTag -wfuoter
  6945.             w mcur - ottag;UC#tu
  6946. #
  6947. # aaa: Li\w' im< asFenage foagngesageeRysze stZyb No  May 16 15:23:37 BST 2000messageeCopyright (c)                        # ASoftwl        #Ltd (1999)#####
  6948.  
  6949. #####################################################as#####
  6950. UnregTagH filerurePath
  6951.     {Self#s $nam =unt}
  6952. ($sTag,na$sInsid T
  6953.         ,
  6954. $Pidden paHash,n$sId, $sFuotTagassword) = @_$sDigess BStyle = $ACB2B->Get('wordDigess'ath2=) =;
  6955. (     sTag !~ /^\// )last;                se                                    
  6956.         I        notpEtintagloCmr})
  6957. ;
  6958. ( $sDigess )                    I                # if thaiatalhremove oagsctnd-ly tchem    h?
  6959.         ;
  6960. ( ref({sInsid T
  6961.         )#) {
  6962. $$sInsid T
  6963.          Bn""e );
  6964.         
  6965.         }
  6966.     ""efitrcng
  6967. )            }} mem    {
  6968.             #)
  6969.         # T    sum                 e surhll wefstctree
  6970. JavaSn ourei-lSis fil$.h2
  6971.  
  6972.         O                wi@Re        # if thaiJavaSn ourealethdanotge thsn ourei-lnoT    whiedsa                    Soi-rentge th     0 -wRejsworshewewl    nthe anotjup bick' $forigitahwhigeacc        #)
  6973.         }
  6974. $sRrst -r#=    w    {
  6975.         $ACGetRrst  -r();    else##Cur - othigeacc        $sRrst -r#=~ s"/[^/]*$"/";e                                            Rimove fiilued fUC            puse @tu
  6976.     Pige\@Fi,
  6977. $sRrst -r;e                                    Sfsse eea<xmhigeacc        puse @tu
  6978.     Pige\@Fi,
  6979. $sRrst -r;e                                    Sfsse eea<xmhige (twire)sa)
  6980.         }
  6981. {
  6982. Samy ($Stsermin$StsHTML_sswyle = $AC
  6983. #
  6984. #ToLastPige(7," " , ng Name
  6985.  
  6986.  
  6987.  
  6988.  
  6989.  
  6990.  
  6991.  
  6992.  
  6993.  
  6994.  
  6995.  
  6996.  
  6997.  
  6998.  
  6999.  
  7000.  
  7001. w    {
  7002.         $ACGetshr    0 (-1, 208),de Name
  7003.  
  7004.  
  7005.  
  7006.  
  7007.  
  7008.  
  7009.  
  7010.  
  7011.  
  7012.  
  7013.  
  7014.  
  7015.  
  7016.  
  7017.  
  7018.  
  7019. \@tu
  7020.     Pige\@Fi,
  7021. $tu
  7022.     sWebSiteUrl,de Name
  7023.  
  7024.  
  7025.  
  7026.  
  7027.  
  7028.  
  7029.  
  7030.  
  7031.  
  7032.  
  7033.  
  7034.  
  7035.  
  7036.  
  7037.  
  7038.  
  7039. $tu
  7040.     sClnh isUrl,     tu
  7041.     pSetup            
  7042. , %tu
  7043.     InputHash",wn tr
  7044.         
  7045.         if ($Siel, 2)###
  7046. R                I        eventge thdidn'taworkr-            #givewup -e        # if thans:  0  sem    re
  7047.                     {
  7048.         $ACReportermin(tsermin$Syle = $ACGetsub (<",wn trr}h2=) =                {
  7049.         $ACAss NoIs                v"ssw$::TRUE;else##Chrwtr    # ifs_)i            esureen aoaPRL =Pigeemodun'ta whiuXML    m
  7050. #0 r t                {
  7051.         $ACPRL =Pige(tsHTML, ASSER,w$::TRUE);            PRL =wwl    nthe p($s    tnd-exitchem    exitd)     }#    
  7052.  
  7053.         }
  7054.     $eFuotTag;;
  7055.         ng
  7056.             }
  7057.         }
  7058.  ""efit})
  7059.  
  7060.  
  7061.  
  7062. ############################################################## 
  7063. PricFTagH fileru-epricFdoag  whibickmessageeAvalid asn:     sTag -wtagded fUC# aaaaaaaaaaaaa$sInsid T
  7064.          -wList - referer
  7065.             betwee# if thdanot< $,UC# aaaaaaaaaaaaa$Pidden paHash#-ehase w mhidden pas,UC# aaaaaaaaaaaaa$sIri-rcur - ottagdpresix,UC# aaaaaaaaaaaaa$sFuotTag -wfuoter
  7066.             w mcur - ottag;UC#tu
  7067. #
  7068. # aaa: noth soscterLi\w' is $sInsid T
  7069.          by  etabiliw mhricFsngesageeRysze stZyb No  Dec  7 21:06:24 GMT 1999messageeCopyright (c)                        # ASoftwl        #Ltd (1999)###mes##
  7070.  
  7071. #####################################################as#####
  7072. PricFTagH filerurePath
  7073.     {Self#s $nam =unt}
  7074. ($sTag,na$sInsid T
  7075.         ,
  7076. $Pidden paHash,n$sId, $sFuotTagassword) ==) =;
  7077. (     sTag !~ /^\// )last;                se                                    
  7078.         I        notpEtintagloCmr})
  7079. ;
  7080. ( $    elf->{Cur - oSectper            
  7081. } )last;                se                            I        sectper b        
  7082. h#etd va    {)
  7083.         }
  7084. @Respons(site        #)
  7085.         # Weeneedage foaxiinutrings fa $f whculaeaage fhricFsnge        #)
  7086.         ;
  7087. (!$                    # O sam::bTaxDataP
  7088. #0 d) mem    re
  7089.                 #
  7090.                 # "rw"age foaxib        
  7091.  
  7092.                 #
  7093.                 @Respons(sswyle = $AC
  7094. adTaxSetupFRle(yle = $ACGetsub (<",wn trr
  7095.         
  7096. Respons([0]$Siel, 2)###
  7097. R mem    re{
  7098.                     
  7099.         }
  7100.     r@Respons();;
  7101.         ));
  7102.             )                    # O sam::P
  7103. #0 Adva redTax();;
  7104.         );
  7105.             $    elf->P
  7106. #0 (${sInsid T
  7107.         );?
  7108.  
  7109.             @Respons(sswyle = $ACGetsroduct($Pidden paHash->{PROD_REF},w$    elf->{Cur - oSectper            
  7110. },de Name
  7111.  
  7112.  
  7113.  
  7114.  
  7115.  
  7116.  
  7117.  
  7118.  
  7119.  Syle = $ACGetsub (<",se                            g    tege thproduc        wbject)
  7120.         }
  7121. {
  7122. Samy ($Status, $, EpsroductasswoRespons(site        
  7123.         
  7124.         if ($Siel, 2)###
  7125. R ng NamS ##    tt    
  7126.         }
  7127.     ""efitrc    }t;                se                            I        ed bprobilm,sFengetpit
  7128. h2(
  7129.  
  7130. ;
  7131.     rSERis r $Epsroduct{PRICES}) mem    re
  7132.                 #
  7133.                 # Ne ris_)kmewree
  7134. ge thproduc        hasead bth t nts?
  7135.             #
  7136.                 }
  7137. {
  7138. Vh t nt\@Fi,
  7139. $sLss );
  7140.                 ;
  7141. (     psroduct->{COMPONENTS} ) mem    rre
  7142.                     {
  7143. Vh t nt\@Fi,
  7144. $sLss )sswyle = $ACGetVh t nt\@Fi($Pidden paHash->{PROD_REF});;
  7145.         ));
  7146.             )#
  7147.                 # Ne ris_)workr ErrmTRACEhricFsis_);how    {
  7148.         #
  7149.                 }
  7150. {
  7151. bShowRse\"lPricF($StbShowCuuesmerPricF($StnAy the Sccedul )sswyle = $ACDn pamss PricF(ToShow();;
  7152.         )
  7153.                 }
  7154. $sPricFLabelT
  7155.         ss     yle = $ACB2B->GetXML('RETAIL_PRICE_TEXT');
  7156.                 ;
  7157. (
  7158. bShowRse\"lPricF( &&StbShowCuuesmerPricF() mem    rre
  7159.                     }
  7160. $sPricFLabelsswyle = $ACGetshr    0 (-1, 294,
  7161. $sPricFLabelT
  7162.         );;
  7163.         ))#;
  7164.         ))# Showrdtheernernarse\"l    pricF;
  7165.         ))#;
  7166.         ))@Respons(sswy                # O sam::FtringSccedul PricF((    psroduct, ng Name
  7167. 1, \
  7168. Vh t nt\@Fi,
  7169. $sPricFLabel, 1);e                                    Showrd wiree\"l    pricF;
  7170.         ))$$sInsid T
  7171.          Bn
  7172. Respons([2];?
  7173.             e mem    rr    sPricFLabelsswyle = $ACGetshr    0 (-1, 293,
  7174. $sPricFLabelT
  7175.         );;
  7176.         ))@Respons(sswy                # O sam::FtringSccedul PricF((    psroduct, ng Name
  7177. tnAy the Sccedul , \
  7178. Vh t nt\@Fi,
  7179. $sPricFLabel);                    Showrd widtheernpricF;
  7180.         ))$$sInsid T
  7181.          .Bn
  7182. Respons([2];?
  7183.             e;
  7184.             )        };
  7185. (
  7186. bShowCuuesmerPricF() mem    rre
  7187.                     #;
  7188.         ))# Showre surdtheernpricF;
  7189.         ))#
  7190.                     ;
  7191.  (0ry= s whar(@{    psroduct->{'PRICES'}->{    nAy the Sccedul }}))##tName
  7192. e
  7193.                         #
  7194.                         #    T    #iproduc         thanavailabili;
  7195.  atal'sepricFdsccedul !! Tnotpincluded
  7196.                         #
  7197.                         $$sInsid T
  7198.          Bn    {
  7199.         $ACGetshr    0 (-1, 351);            'Te thproduc         th ur - osuranavailabil'    {
  7200.         ));
  7201.             )            }}            se                            atal'sepricFdsccedul !!ncluded
  7202.                         e
  7203.                         @Respons(sswy                # O sam::FtringSccedul PricF((    psroduct, ng Name
  7204.  
  7205. tnAy the Sccedul , \
  7206. Vh t nt\@Fi,
  7207. $yle = $ACB2B->GetXML('RETAIL_PRICE_TEXT'));;
  7208.         )))$$sInsid T
  7209.          Bn
  7210. Respons([2];?
  7211.             e
  7212. };
  7213.         ));
  7214.             )        }} mem    rre
  7215.                     #;
  7216.         ))# Showre surrse\"l    pricF;
  7217.         ))#;
  7218.         ));
  7219.  (0ry= s whar(@{    psroduct->{'PRICES'}->{    y                # O sam::RETAILID}}))##tName
  7220. e
  7221.                         #
  7222.                         #    T    #iproduc         thanavailabili;
  7223.  d wiree\"l    pricF!! Tnotpincluded
  7224.                         #
  7225.                         $$sInsid T
  7226.          Bn    {
  7227.         $ACGetshr    0 (-1, 351);            'Te thproduc         th ur - osuranavailabil'    {
  7228.         ));
  7229.             )            }}
  7230.                         e
  7231.                         @Respons(sswy                # O sam::FtringSccedul PricF((    psroduct, ng Name
  7232.  
  7233. 1, \
  7234. Vh t nt\@Fi,
  7235.  
  7236. $yle = $ACB2B->GetXML('RETAIL_PRICE_TEXT'));;
  7237.         )))$$sInsid T
  7238.          Bn
  7239. Respons([2];?
  7240.             e
  7241. };
  7242.         ));
  7243.             )}
  7244.             ng
  7245.             }
  7246.         }
  7247.  ""ee                                                    ast;                se            Alwayshremove oagfit})
  7248.  
  7249.  
  7250.  
  7251. ########################################################### 
  7252. ###
  7253. SectperTagH filer #    s    ctper eag  whibickmessageeNote:-<                    # :SE{
  7254. ON BLOB="b        
  7255. hfiilued f"/> actthg        
  7256. poteUC# aaaaaaa$    elf->{Cur - oSectper            
  7257. }  th#etp    # if    rnakeptmessageeAvalid asn:     sTag -wtagded fUC# aaaaaaaaaaaaa$sInsid T
  7258.          -wList - referer
  7259.             betwee# if thdanot< $,UC# aaaaaaaaaaaaa$Pidden paHash#-ehase w mhidden pas,UC# aaaaaaaaaaaaa$sIri-rcur - ottagdpresix,UC# aaaaaaaaaaaaa$sFuotTag -wfuoter
  7260.             w mcur - ottag;UC#tu
  7261. #
  7262. # aaa: noth soscterse s-$    elf->{Cur - oSectper            
  7263. } ao  fielal lhidden parBLOBngesageeRysze stZyb No  Dec  20 21:06:24 GMT 1999messageeCopyright (c)                        # ASoftwl        #Ltd (1999)#####
  7264.  
  7265. #####################################################as#####
  7266. SectperTagH filerurePath
  7267.     {Self#s $nam =unt}
  7268. ($sTag,na$sInsid T
  7269.         ,
  7270. $Pidden paHash,n$sIdassword) =) =;
  7271. (     sTag !~ /^\// )last;                se                    I        notpEtintagloCmr})
  7272. $    elf->{Cur - oSectper            
  7273. } nC$Pidden paHash->{BLOB}s##    t}h2
  7274.         }
  7275.     ""e                        ast;                se            Alwayshremove oagfit})
  7276.  
  7277.  
  7278.  
  7279. ########################################################### 
  7280. ###
  7281. M\" Fc$sFTagH filer### 
  7282. Li\w' i SRCuhidden par!n    awFRAMEfoagnge ange aIftMAINFRAME-XML    th t filai-lSERis rianotSRC=ed f isafe nonge a!n    insid er
  7283.         ,ded f                  eedLi\w' id by d wi fielal lMAINFRAME-XMLnge ath t fil.loOtusagee
  7284. aAvalid asn:     sTag -wtagded fUC# aaaaaaaaaaaaaaa$sInsid T
  7285.          -wList - referer
  7286.             betwee# if thdanot< $,UC# aaaaaaaaaaaaaaa$Pidden paHash#-ehase w mhidden pas,UC# aaaaaaaaaaaaaaa$sIri-rcur - ottagdpresix,UC# aaaaaaaaaaaaaaa$sFuotTag -wfuoter
  7287.             w mcur - ottag;UC#tutu
  7288. #
  7289. # aaa: noth soscterile tiis $$sInsid T
  7290.         ngesageeRysze stZyb No  Jul 18 11:26:08 BST 2000messageeCopyright (c)                        # ASoftwl        #Ltd (2000)#####
  7291.  
  7292. #####################################################as#####
  7293. M\" Fc$sFTagH filer##ePath
  7294.     {Self#s $nam =unt}
  7295. ($sTag,na$sInsid T
  7296.         ,
  7297. $Pidden paHash,n$sIdassword) =) =;
  7298. (     sTag !~ /^\// )last;                se                    I        notpEtintagloCmr})
  7299.  @_$sXMLTagth2    
  7300. ;
  7301. ( $tu
  7302.     InputHash{MAINFRAMEURL} ) mem    h?
  7303.             sXMLTagd= ttu
  7304.     InputHash{MAINFRAMEURL}efitrcng
  7305. )            }} mem    {
  7306.             $sXMLTagd= tyle = $ACB2B->GetXML("MAINFRAMEURL");;
  7307.         ng
  7308.     ;
  7309. ( SERis r(    sXMLTag)#)sse                                            Ri\w' i SRCuhidden parby dagd field va    {)
  7310.         ;
  7311. ( ref({sInsid T
  7312.         )#) mem    re
  7313.                 ;
  7314. (     sXMLTagd!~ /^((http:)|(\/))/ ) mem    rre
  7315.                     ;
  7316. (     sXMLTagdeq 'lc$sFset.html' )##tName
  7317. e
  7318.                             sXMLTagd= 'catalogbody.html'?
  7319.             e
  7320. };
  7321.         ))    sXMLTagd= ttu
  7322.     sAy the Sc oure. '?'#. 'PRODUCTPAGE='#. $sXMLTagth2    
  7323.     e
  7324. };
  7325.         )$$sInsid T
  7326.          B~ s/(\s+SRC\s*=\s*)((\"[^\"]+\")|([^\ \>]+))((\s+)|(\>+))/$1\"$sXMLTag\"$5/is;
  7327.             )}
  7328.             ng
  7329.             }
  7330.         }
  7331.  ""ee                                                    ast        Alwayshremove oagfit})
  7332.  
  7333.  
  7334. ########################################################### 
  7335. FtringPricF -wftring sionLE pricF;
  7336. Otusagee
  7337. Avalid as:     $PricF -wpricFdoolSis\w'y    }#    
  7338.  
  7339.  
  7340.  
  7341. sPricFMsg -wpricFdhcteptsageeame
  7342.  
  7343. $sTax -wtaxiinutsageeame
  7344.  
  7345. $sIncTax -wincludthe saxiinutsageeame
  7346.  
  7347. $bTaxExlu pveO sur-lSis\w'y saxiexclu pvere susageeame
  7348.  
  7349. $bTaxInclu pveO sur-lSis\w'y saxiinclu pvere susagee
  7350.  
  7351. #
  7352. # Reftringa-dllricF!!nutsagsageeRysze stZyb No  Dec 29 23:07:05 GMT 1999messageeCopyright (c)                        # ASoftwl        #Ltd (1999)#####
  7353.  
  7354. #####################################################as#####
  7355. FtringPricF##ePath
  7356.     {Self#s $nam =unt}
  7357. ($PricF,$sPricFMsg,$sTax,$sIncTax,$bTaxExlu pveO su,$bTaxInclu pveO suassword) = @_($sPricF,$sEPricF,$fPricF,$sPricFexl,$sPricFincl);?
  7358.  
  7359.     }
  7360. $sCur - cyeeam= ttu
  7361.     pCatalog            
  7362. ->{SCURRENCY}d) = @_$sEFtring  n    m= ttu
  7363.     pSetup            
  7364. ->{EURO_FORMAT}d) = @_$sECur - cyeam= ttu
  7365.     pCatalog            
  7366. ->{EUR}->{SCURRENCY}d) = @_$fEuroConv N perm= ttu
  7367.     pCatalog            
  7368. ->{EUR}->{EXCH_RATE}d) = @_$sPFtring            = '%s%.2f'd)     }
  7369. ;
  7370. (     bTaxExlu pveO sur)last;                    se                                # Exlu pvere susaCmr})
  7371. $fPricF nC$PricF/100.0;last;                se                                # PricF!!n "rwlrilneusaCm}        e me        }e    else                                    se                                        # Inclu pvere    #bofisaCmr})
  7372. $fPricF nC(1.0 + ttu
  7373.     pSetup            
  7374. ->{TAX_1_RATE}/10000.0) *C$PricF/100.0;las        Add saxg
  7375.             }
  7376. ;
  7377. ( !$bTaxInclu pveO suranot!    bTaxExlu pveO sur)last;                    s# Dis\w'y exclu pveranotinclu pverhricFsnge    r})
  7378. $sPricFexl  = smRL =f($sPFtring,$sCur - cy,$PricF/100.0);e                                    Ftring exlu pverhricF})
  7379. $sPricFincl = smRL =f($sPFtring,$sCur - cy,$fPricF);last;                s        Fssing inclu pverhricFh2    
  7380. ;
  7381. ( $tu
  7382.     pSetup            
  7383. ->{EURO_PRICES}r)last;                    se            # EuroEhricFsiee
  7384. meeded mem    {
  7385.             $sEPricF#  ss $mRL =f($sPFtring,$sECur - cy,$PricF/$fEuroConv N per/100.0);e# C lculaeaaEuroEexclu pverpricF;
  7386.         $sPricFexl  = smRL =f($sEFtring,$sPricFexl,$sEPricF);last;                        Ftring exclu pverpricFiif the##            $sEPricF#  ss $mRL =f($sPFtring,$sECur - cy,$fPricF/$fEuroConv N per);                    C lculaeaaEuroEinclu pverhricFh2    
  7387. $sPricFincl = smRL =f($sEFtring,$sPricFincl,$sEPricF);last;                    Fssing inclu pverhricFiif the##            );
  7388.     
  7389.         }
  7390.         {
  7391.         $ACGetshr    0 (-1,227,$sPricFMsg,$sPricFexl,$sPricFincl,$sIncTaxns##    t}h2h2(    sPricF nCsmRL =f($sPFtring,$sCur - cy,$fPricF);last;                s                Fssing hricFh2    ;
  7392. ( $tu
  7393.     pSetup            
  7394. ->{EURO_PRICES}r)last;                    se            s        Add EuroEhricFiee
  7395. meeded memr})
  7396. $sEPricF nCsmRL =f($sPFtring,$sECur - cy,$fPricF/$fEuroConv N per);                            C lculaeaaEuroEhricF})
  7397. $sPricF  = smRL =f($sEFtring,$sPricF,$sEPricF);last;                s                Fssing iampleteuhricFiif the##                }
  7398.         }
  7399.      {
  7400.         $ACGetshr    0 (-1,225,$sPricFMsg,$sPricF,$sTax);fit})
  7401.  
  7402.  
  7403. ########################################################### 
  7404. FtringPricFRowt:    fssing hricFerow    {Otusagee
  7405. Avalid as:     $PricF -wpricFdoolSis\w'y    }#eeame
  7406.  
  7407. $sIncTax -wincludthe saxiinutsag                            sQlimi     -wquantityiinutsageeame
  7408.  
  7409. $bTaxExlu pveO sur-lSis\w'y saxiexclu pvere susageeame
  7410.  
  7411. $bTaxInclu pveO sur-lSis\w'y saxiinclu pvere susagee
  7412.  
  7413. #
  7414. # Reftringa-dllricF!!nutsagsageeRysze stZyb No  Dec 29 23:07:05 GMT 1999messageeCopyright (c)                        # ASoftwl        #Ltd (1999)#####
  7415.  
  7416. #####################################################as#####
  7417. FtringPricFRow    {
  7418. Path
  7419.     {Self#s $nam =unt}
  7420. ($PricF,$sIncTax,$sQlimi    ,$bTaxExlu pveO su,$bTaxInclu pveO suassword) = @_($sPricF,$sEPricF,$fPricF,$sPricFexl,$sPricFincl);?
  7421.  
  7422.     }
  7423. $sCur - cyeeam= ttu
  7424.     pCatalog            
  7425. ->{SCURRENCY}d) = @_$sEFtring  n    m= ttu
  7426.     pSetup            
  7427. ->{EURO_FORMAT}d) = @_$sECur - cyeam= ttu
  7428.     pCatalog            
  7429. ->{EUR}->{SCURRENCY}d) = @_$fEuroConv N perm= ttu
  7430.     pCatalog            
  7431. ->{EUR}->{EXCH_RATE}d) = @_$sPFtring            = '%s%.2f'd)     }
  7432. ;
  7433. (     bTaxExlu pveO sur)last;                    se                                    # Exclu pvere susaCmr})
  7434. $fPricF nC$PricF/100.0;last;                se                                    # PricF!!n "rwlrilneusaCm}     me        }e    else                                    se                                            # Inclu pvere    #bofisaCmr})
  7435. $fPricF nC(1.0 + ttu
  7436.     pSetup            
  7437. ->{TAX_1_RATE}/10000.0) *C$PricF/100.0;lass        Add saxg
  7438.             }    }
  7439. ;
  7440. ( !$bTaxInclu pveO suranot!    bTaxExlu pveO sur)last;                    ss# Dis\w'y exclu pveranotinclu pverhricFsnge    r})
  7441. $sPricFexl  = smRL =f($sPFtring,$sCur - cy,$PricF/100.0);e                                    Ftring exclu pve})
  7442. $sPricFincl = smRL =f($sPFtring,$sCur - cy,$fPricF);last;                s        Fssing inclu pveh2    
  7443. ;
  7444. ( $tu
  7445.     pSetup            
  7446. ->{EURO_PRICES}r)last;                    se            # Add EuroEhricFiee
  7447. meeded mem    {
  7448.             $sEPricF#  ss $mRL =f($sPFtring,$sECur - cy,$PricF/$fEuroConv N per/100.0);e# Exclu pve})
  7449.     $sPricFexl  = smRL =f($sEFtring,$sPricFexl,$sEPricF);##            $sEPricF#  ss $mRL =f($sPFtring,$sECur - cy,$fPricF/$fEuroConv N per);                    Inclu pve})
  7450.     $sPricFincl = smRL =f($sEFtring,$sPricFincl,$sEPricF);fitrc}})
  7451. ;
  7452. (         elf->{Vh t file}->{FORMAT_PRICE_ROW_BOTH} )se                                            I                # if thaith t fil,xatasit mem    S)
  7453.         
  7454.         }
  7455.     smRL =f($    elf->{Vh t file}->{FORMAT_PRICE_ROW_BOTH},$sPricFexl,$sPricFincl,$sIncTax,$sQlimi    );fitrc}    ##
  7456.             }e    else                                    se                                
  7457.         O                wi@ReusFdhctept 228 mem    S)
  7458.         
  7459.         }
  7460.         {
  7461.         $ACGetshr    0 (-1,228,$sPricFexl,$sPricFincl,$sIncTax,$sQlimi    );fitrc}##    t}h2h2(    sPricF nCsmRL =f($sPFtring,$sCur - cy,$fPricF);last;                s                Dis\w'y ei        # dexclu pverer inclu pveh2    ;
  7462. ( $tu
  7463.     pSetup            
  7464. ->{EURO_PRICES}r)last;                    se            s        Add EuroEhricFsiee
  7465. meeded memr})
  7466. $sEPricF nCsmRL =f($sPFtring,$sECur - cy,$fPricF/$fEuroConv N per);})
  7467. $sPricF  = smRL =f($sEFtring,$sPricF,$sEPricF);g
  7468.             }
  7469. ;
  7470. ( $    elf->{Vh t file}->{FORMAT_PRICE_ROW} )last;                se                    I                # if thaith t fil,xatasit mem{;
  7471.     
  7472.         }
  7473.     smRL =f($    elf->{Vh t file}->{FORMAT_PRICE_ROW},$sPricF,$sQlimi    );fitr} me        }e    else                                    se                                            # O                wi@ReusFdhctept 224 mem{;
  7474.     
  7475.         }
  7476.         {
  7477.         $ACGetshr    0 (-1,224,$sPricF,$sQlimi    );fitr} me})
  7478.  
  7479.  
  7480.  
  7481. ################################################################# 
  7482. ick($s    SimpleLockr-    port filafiilulockthe moduil###sageWriga-nrby Zoltan Bodi###sageCopyright (c)                        # ASoftwl        #Ltd 2000messag
  7483.  
  7484. #############################################################sageUs, $:messag= @_$rLckr=
  7485.  - tSimpleLock('../atals.das'ath2#    }
  7486. $nRe     Bn
  7487. rLck->Lock(",se                            trydoolg    tegelulockh2#    
  7488.         
  7489. nRe     Bs         impleLock, 2)###
  7490. R m#em{;
  7491. #                ataegelulockedeeiiluthripS#tr} m#)        };
  7492.     
  7493. nRe     Bs         impleLock, ERR_TIMEOUTR m#em{;
  7494. #                a time Errhaseoccureoititr} m#)        };
  7495.     
  7496. nRe     Bs         impleLock, ERR_DIRPERM
  7497. R m#em{;
  7498. #                eiiluppamss per probilmsititr} m#)        };
  7499.     
  7500. nRe     Bs         impleLock, FAILURER m#e
  7501. rLck->Unlock(",se                                # "rleataegelulock m#e(Noteen aoagelulockf thautoings whiy "rleata$#on geluwbject'-lSEif uctper.R m#e m#e m#as##
  7502. ick($s        impleLock;;
  7503. rCe!v
  7504. #0 qw($2)###
  7505.  $ERR_TIMEOUT $ERR_DIRPERM
  7506.  $ERR_OPNANDLCK $ERR_NOOPNNOLCK;
  7507.         )$ERR_MORELCK $ERR_STALELCK $ERR_RECURSE $FAILURE_$s_sHosted f);;
  7508.         )
  7509. $2)###
  7510.  = 0th2$FAILURE_= -1th2$ERR_TIMEOUT _= 1,se                                # time Errwair sosferInulock m$ERR_DIRPERM
  7511.  = 2,se                                # insuffici- ot(directoruasppamss pers m$ERR_OPNANDLCK = 3,se                                # insanFiifate:-bofie.OPNranot.LCK presd a##$ERR_NOOPNNOLCK = 4,se                                # insanFiifate:-nk lio
  7512.  d wiabove l        #presd a##$ERR_MORELCK = 5;e                            
  7513.         # insanFiifate:-ssse .LCK eiils m$ERR_STALELCK = 6,se                                # ifailulockeiiludetecteoit$ERR_RECURSE = 7;e                            
  7514.         # recuN per detecteoitit$s_sHosted f#=    '';                            
  7515.         # hosted f# th#fssedp    # ifo ref
  7516.         rieveoitit#
  7517.  
  7518. #################################################################     impleLock,  - t-ulockfwbject
  7519. alur     uctor. Noteen aoageluLock("sageemethodfshouldneed    whieddoolactuwhiy acquiraegelulock.loOtnge aInput:    (clorred f)sag                bataeeiiled fmsFenage flock m#sag    
  7520. #
  7521. # RefilesedwList - refererelulockfwbject)
  7522. ssag
  7523.  
  7524. #############################################################sa###
  7525.  -     {
  7526. Path
  7527.     {rSelf#s {};e                            
  7528.         # c"rwteeaehase Fenage fwbject)
  7529. }
  7530. $sThiss $nam =                            
  7531.         
  7532.     }
  7533. $sClorrny ref({sThis)||{sThis;                            g    tegelued f Fenage fclorrh2(    r    elf->{batan$sF}s $nam =unt    r    elf->{locked}=0d)     }
  7534.     r    elf->{nRe    rytime}s 0.2;                            # timeis_)wair    betwee# 
  7535.         ries    }
  7536.     r    elf->{nRe    ries} _= 50;                            # tofai nurns:    w m
  7537.         ries    }
  7538.     r    elf->{ifail($s} nC120;# 3600;                    # ifailu($s    limi     inesealuds    }
  7539.     r    elf->{recuN e_level}i= 0th2(    r    elf->{hostID}i= _g    t_site_ID(ath2=) =files        r    elf,$sClorr; me})
  7540.  
  7541.  
  7542.  
  7543. #################################################################     impleLock, DESTROYr-    der     uctor. Noteen aoagelulockf th"rleata$#nge aon geluwbject'-lSEif uctper.loOtnge aInput:    nk li(jsworge fclorred f)sagsag    
  7544. #
  7545. # Ren/a t(don'ta whiuge thmethodfexplicitly))
  7546. ssag
  7547.  
  7548. #############################################################sa###
  7549. DESTROY    {
  7550. Path
  7551.     {rSelf=$nam =unt    r    elf->Unlock; me})
  7552.  
  7553.  
  7554.  
  7555. ################################################################## _    ry_ran$sFr-    Trydoolg    tegelulockrby ran$s sos'batan$sF'.OPNroolsag    'batan$sF'.LCK.<HOST>.<PID>. Nor publichmethod.sag        sag    Input:    batan$sFsagsag    
  7556. #
  7557. # Ref uwi fiela;
  7558.  d wireed f  asesuwritsful, o                wi@Refa    }} mssag
  7559.  
  7560. #############################################################sa###
  7561. _    ry_ran$sF    {
  7562. Path
  7563.     {rSelf#s $nam =unt}
  7564. $sHostID Bn
  7565. r    elf->{hostID}d) =) = @_$fn#s $nam =unt;
  7566.     
  7567. ran$sF("$fn.OPN","$fn.LCK.$sHostID")) mem{;
  7568.     
  7569.         }
  7570.     1;e                            
  7571.         # reed f  asesuwritsfulfitr} me        }e mem{;
  7572.     
  7573.         }
  7574.     0;e                            
  7575.         #  asenotpsuwritsfulfitr} me})
  7576.  
  7577.  
  7578.  
  7579. ################################################################## _    ry_ran$sF_bick'-    Trydool"rleataegelulockrby ran$s sos'batan$sF'.LCK.PIDlsag    ool'batan$sF'.OPN. Nor publichmethod.sag        sag    Input:    batan$sFsagsag    
  7580. #
  7581. # Ref uwi fiela;
  7582.  d wireed f  asesuwritsful, o                wi@Refa    }} mssag
  7583.  
  7584. #############################################################sa###
  7585. _    ry_ran$sF_bickme
  7586. Path
  7587.     {rSelf#s $nam =unt}
  7588. $sHostID Bn
  7589. r    elf->{hostID}d) = @_$fn#s $nam =unt;
  7590.     
  7591. ran$sF("$fn.LCK.$sHostID","$fn.OPN"))
  7592.         # reed f  asesuwritsfulfitr{;
  7593.     
  7594.         }
  7595.     1;fitr} me        }e mem{;
  7596.     
  7597.         }
  7598.     0;e                            
  7599.             #  asenotpsuwritsfulfitr} me})
  7600.  
  7601.  
  7602.  
  7603. ################################################################### _                nup -eTrydooldeleteeaotelockeiilthassociateddoold wigive#UC#    batan$sF.sag        sag    Input:    batan$sFsagsag    
  7604. #
  7605. # Re        impleLock, 2)###
  7606. ,sag                        impleLock, ERR_DIRPERM
  7607. ,a;
  7608.  d widirectoru#caemeteeedLiad mssag
  7609.  
  7610. #############################################################sa###
  7611. _                nupme
  7612. Path
  7613.     {fns $nam =unt;
  7614.     
  7615. raf({fn))se                                            G    tegelubatan$sFa;
  7616.      nmkbject
  7617. List - re.saCmr})
  7618. $fn->{locked}i= 0th2(
  7619. $fn#s $fn->{batan$sF};fitr} me
  7620.     {bn Bn    {_Batan$sF::batan$sF({fn)d) = @_@pids;
  7621.     {nless= 0th2(;
  7622.     
  7623. !nlesdir DH,n    {_Batan$sF::dirn$sF({fn)) mem{;
  7624.     
  7625.         }
  7626.     $ERR_DIRPERM
  7627. ;                    
  7628.         # re    }
  7629.     :  0 a;
  7630.          #caemete"rw"age fdirectorufitr} memTRle ($_="rw"dir DH)loCmr})
  7631. ;
  7632.  ($_deq "{bn.OPN")e                                # teluwlesslock mem    S)
  7633.         unlink "$fn.LCK.OPN";                            # deleteetelueiiluus sosfuotepafisaCmt}##
  7634.             }
  7635.  (/{bn\.LCK\.(\S*)\.(-?\d+)$/)                # aec
  7636.     {
  7637. dulockrFenahost $1 pid $2 mem    S)
  7638.         unlink "$fn.LCK.$1.$2";                            # deleteetelueiiluus sosfuotepafisaCmt}##
  7639.     }##
  7640.     c
  7641.     {
  7642. dir DH;;
  7643.     
  7644.         }
  7645.     $2)###
  7646. ; me})
  7647.  
  7648.  
  7649.  
  7650. #################################################################### _ini     -wIni    ializaegelulockrby c"rwtthe ane.OPNrflag.    C liuge t### e surFenalocksre 
  7651.  - ly c"rwtedeeiils. T    sums    l shsomeisime Er### delayaon gelufirsta whiuw mLock(".sag        sag    Input:    batan$sFsagsag    
  7652. #
  7653. # Re        impleLock, 2)###
  7654. ,sag                        impleLock, ERR_DIRPERM
  7655. ,aon eiiluc"rwtter probilms. mssag
  7656.  
  7657. #############################################################sa###
  7658. _ini    me
  7659. Path
  7660.     {rSelf#s $nam =unt}
  7661. $sFn Bn
  7662. r    elf->{batan$sF};fitunlles    (wles(TF, '>'.
  7663. r    elf->{batan$sF}.'.OPN'))            trydoolc"rwteetelueiil mem{;
  7664.     
  7665.         }
  7666.     $ERR_DIRPERM
  7667. ;##
  7668.     }##
  7669. c
  7670.     {
  7671. (TF);e                            
  7672.         # c
  7673.     {
  7674. ei    me
  7675.         }
  7676.     $2)###
  7677. ; me})
  7678.  
  7679.  
  7680.  
  7681. ##################################################################### _do_lockr-    (Trydoo)lg    tegelulock.eD n'ta whiuge thdirectly ### acter Ersid er    #ipick($s. T    sum thaiprivwteemethod.sag        sag    Input:    nk li(excepthe emkbject
  7682. List - re)sagsag    
  7683. #
  7684. # Re        impleLock, 2)###
  7685. ,sag                        impleLock, ERR_DIRPERM
  7686. ,        on eiiluc"rwtter probilms. ms                        impleLock, ERR_TIMEOUT,        time Errer acquirthe shlulock m#e                    impleLock, ERR_NOOPNNOLCK,    nkelockeiilth(unini    ializadiifate) m#e                    impleLock, ERR_STALELCK,        a ifailulockeiiluhasefe nongee                    impleLock, ERR_MORELCK,        ssse c
  7687.     {
  7688. dulockeiils mssag
  7689.  
  7690. #############################################################sa###
  7691. _do_lockme
  7692. Path
  7693.     {rSelf#s $nam =unt}
  7694. $fn Bn
  7695. r    elf->{batan$sF};fit}
  7696. $nRe    ries Bn
  7697. r    elf->{nRe    ries};fit}
  7698. $nRe    rytime Bn
  7699. r    elf->{nRe    rytime};fit}
  7700. $    ry;fitfin(t    ry=0;
  7701. $    ry<$nRe    ries;
  7702. $    ry++)loCmr})
  7703.  @_$mewr=isime;last;                        let's chang er    #imtime o
  7704.  d wiwlesslock memutime($mew,$mew,"$fn.OPN");                    # (t    sum thneededdFenage fdetectter o
  7705.  ifailulock() mem        {
  7706.         Trydooldo d wireed f mem        {
  7707. ;
  7708.  ($r    elf->_    ry_ran$sF({fn)) mem    {
  7709.             $r    elf->{locked}=1;                            # OK,         #hll wshlulock m    
  7710.     
  7711.         }
  7712.     $2)###
  7713. ; mercng
  7714. )            }} mem    {
  7715.             #)
  7716.         # Unsuwritsfulireed f. Wair    ferInumTRle anotgoy  gain
  7717.             #)
  7718.         s    lectV(ASSER,ASSER,ASSER,$nRe    rytime);fitrc}##    t}h2em        {
  7719.         St                nkesuwrits af parse loaiugries.#ChrckrFenapossibilireatonh2em        {
  7720. h2em        {
  7721.         ChrckrFenadirectoru#ppamss pers mem###        }
  7722. $rn Bnint(rano(10000));;
  7723.     }
  7724. $    emped f#=    "$fn.TEMP.$$.
  7725. rn"efitrunlles    ( wles(TF, ">$    emped f.OPN") &&    
  7726.         # c"rwteeae    empueiil mem        
  7727. c
  7728.     {
  7729. (TF) &&    
  7730.                 
  7731.         # c
  7732.     {
  7733. ei    me
  7734.                 $r    elf->_    ry_ran$sF({    emped f) &&    
  7735. # reed f ir    as!!        ioaw# if    ruwlesslock mem            $r    elf->_    ry_ran$sF_bick({    emped f) &&    # reed f ir    bickme
  7736.     
  7737.         unlink("$    emped f.OPN") )                    # delete mem    S)
  7738.         
  7739.         }
  7740.     $ERR_DIRPERM
  7741. ;                    
  7742.         # i        ed bo
  7743.  d w@Refails re    }
  7744.     :  0 fitrc}##    t
  7745.     {bn Bn    {_Batan$sF::batan$sF({fn)d) == @_@pids;
  7746.     {bOless= 0th2((;
  7747.     
  7748. !nlesdir DH,n    {_Batan$sF::dirn$sF({fn)) mem    S)
  7749.         
  7750.         }
  7751.     $ERR_DIRPERM
  7752. ;                    
  7753.         # re    }
  7754.     :  0 a;
  7755.          #caemete"rw"age fdirectorufitrc}##       }
  7756. $fn$sFth2((mTRle ($fed f#=    "rw"dir DH)loCm    {)
  7757.         ;
  7758.  ($fed f#eq "{bn.OPN")e                        # teluwlesslock mem    re
  7759.                     bOless= 1;
  7760.             )}
  7761.                     };
  7762.     
  7763. fed f#=~ /{bn\.LCK\.(\S+)\.(-?\d+)$/)# aec
  7764.     {
  7765. dulockrFenahost $1 pid $2 mem    re
  7766.                 puse @pids, "$1.$2";
  7767.             )}
  7768.             ng
  7769.     c
  7770.     {
  7771. dir DH;;
  7772.         {
  7773. ;
  7774.  ($bOles) e                            
  7775.         # .OPNrpresd a##m    re
  7776.                 ;
  7777.  (s whar @pids)e                        # (at             stmk liinifa refof) .LCK.<HOST>.<PID>  thpresd a##m    rre{
  7778.                     
  7779.         }
  7780.     $ERR_OPNANDLCK;                    # probilm:ulockf th!n    invalidiifate;
  7781.         ));
  7782.             )        }}e                            
  7783.         # nke.LCK.<HOST>.<PID>##m    rre{
  7784.                     
  7785.         }
  7786.     $ERR_TIMEOUT;                        # teoughulockf thwlessmewret  asea time Er    ;
  7787.         ));
  7788.             }##
  7789.             }e    else                                # .OPNr! Tnotppresd a##m    re
  7790.                 ;
  7791.  (s whar @pidsn=BS1)                        # exactly k li.LCK.<HOST>.<PID>  thpresd a##m    rre{
  7792.                     #;
  7793.         ))# Te thmeansen aoagelulockf th!n    aw(sanF)eoccupiediifate;
  7794.         ))#
  7795.                     }
  7796. $lockn#=    "$fn.LCK.".$pids[0];?
  7797.             e mem    rr}
  7798. $($s    =w(sfat($lockn))[9];?
  7799.             e @_$mewr=isime;;
  7800.         ));
  7801.  ($mew-$($s    >     r    elf->{ifail($s})            sela;
  7802.  d wilockf thwlder oh    nmd wiifailulimi    ##tName
  7803. e
  7804.                         
  7805.         }
  7806.     $ERR_STALELCK;    {
  7807.         ));
  7808.             )            }} mem    rr
  7809. e
  7810.                         
  7811.         }
  7812.     $ERR_TIMEOUT;?
  7813.             e
  7814. };
  7815.         ));
  7816.             )        };
  7817.  (s whar @pids)e                        # ssse .LCK.<HOST>.<PID> l        #presd a##m    rre{
  7818.                     
  7819.         }
  7820.     $ERR_MORELCK;;
  7821.         ));
  7822.             )        }}e                            
  7823.             # .LCK.<HOST>.<PID>  thnotppresd a##m    rre{
  7824.                     #;
  7825.         ))# Unini    ializadiifate
  7826.                     #;
  7827.         ))
  7828.         }
  7829.     $ERR_NOOPNNOLCK;;
  7830.         ));
  7831.             }##
  7832. }h2=) #
  7833.  
  7834. ##################################################################### Lockr-    PublichmethodrFenag    ttthe shlulock. sag        sag    Input:    nk li(excepthe emkbject
  7835. List - re)sagsag    
  7836. #
  7837. # Re        impleLock, 2)###
  7838. ,sag                        impleLock, ERR_TIMEOUT,        time Errer acquirthe shlulock m#e                    impleLock, ERR_DIRPERM
  7839. ,        on eiiluc"rwtter probilms m#e                    impleLock, FAILURE,        sfailu ifo                  nup/ini    ializwtter m#e            (        impleLock, RECURSE,        sintertahwrecuN per detecteo)messag
  7840.  
  7841. #############################################################sageNoteen aoage th     lls itself#recuN pvely k m
  7842.         riessctertaketh      ifnotpool"ur away.sa###
  7843. Lockme
  7844. Path
  7845.     {rSelf=$nam =unt;
  7846.     
  7847. ++    r    elf->{recuN e_level}i>= 5)e                        # cceck    n aoawe l        #notploopthe !n "rcuN e mem{;
  7848.     
  7849.         }
  7850.     $ERR_RECURSE;;
  7851.     #
  7852.         }
  7853.     $ERR_FAILURE;g
  7854.             }
  7855. ;
  7856.  ($r    elf->{locked})loCmr})
  7857. $r    elf->{recuN e_level}--;;
  7858.     
  7859.         }
  7860.     ($2)###
  7861. );fitr} me
  7862.     {re     Bn
  7863. r    elf->_do_lock();    }
  7864. ;
  7865.  ($re     Bs         )###
  7866. R mem{h2em        {
  7867.         Suwritsfully gotegelulock.loem        {
  7868. $r    elf->{recuN e_level}--;;
  7869.     
  7870.         }
  7871.     $2)###
  7872. ;e                            
  7873.             # suwritsfully gotegelulockfitr} me        };
  7874.  ($re     Bs     ERR_TIMEOUTR mem{h2em        {
  7875.         A time Errhaseoccureo.loem        {
  7876. $r    elf->{recuN e_level}--;;
  7877.     
  7878.         }
  7879.     $ERR_TIMEOUT                            
  7880.             #      #hldea time Erfitr} me        };
  7881.  ($re     Bs     ERR_STALELCKR mem{h2em        {
  7882.         A ifailulockrhasebee# detecteo.    
  7883.  
  7884.         nup anotgoy  gain.loem        {
  7885. _                nup(
  7886. r    elf->{batan$sF});;
  7887.     }
  7888. $re     Bn
  7889. r    elf->Lock();    }
  7890. $r    elf->{recuN e_level}--;;
  7891.     
  7892.         }
  7893.     ($
  7894.         ==        )###
  7895. R?        )###
  7896. :$FAILURE;g
  7897.             }
  7898.         };
  7899.  ($re     Bs     ERR_DIRPERM
  7900. R mem{h2em        {
  7901.         A (possibil) probilmdrifiedirectoru#ppamss pers mem###        
  7902.         }
  7903.     $ERR_DIRPERM
  7904. ;##
  7905.     }##
  7906.         };
  7907.  ($re     Bs     ERR_NOOPNNOLCKR mem{h2em        {
  7908.         Unini    ializad.wIni    ializaegelulockriruwlessifate
  7909.         #fitrunlles    ( wles(TF, '>'.
  7910. r    elf->{batan$sF}.'.OPN') &&    # c"rwteeueiil mem        
  7911. c
  7912.     {
  7913. (TF) )e                            
  7914.         # c
  7915.     {
  7916. ei    me
  7917. m    {
  7918.             $r    elf->{recuN e_level}--;;
  7919.          
  7920.         }
  7921.     $ERR_DIRPERM
  7922. ;##
  7923.     );
  7924.         s    lect(ASSER,ASSER,ASSER,.5);e                                    wair    numTRle;
  7925.     }
  7926. $re     Bn
  7927. r    elf->Lock();e                                # trydoolg    tei    me
  7928. m$r    elf->{recuN e_level}--;;
  7929.     
  7930.         }
  7931.     ($
  7932.         ==        )###
  7933. R?        )###
  7934. :$FAILURE;
  7935.         # re    }
  7936.     suwrits ;
  7937.  OK##
  7938.     }##
  7939.         };
  7940.  ($re     Bs     ERR_OPNANDLCK || $re     Bs     ERR_MORELCK)        Invalidiifatusnge    r})
  7941. _                nup(
  7942. r    elf->{batan$sF});                    
  7943.         # remove e loyulockeiils m        # ini    ializaegelulockriruwlessifate
  7944.         unlles    ( wles(TF, 
  7945. r    elf->{batan$sF}.'.OPN') &&        # c"rwteeteluwlesslockueiil mem        
  7946. c
  7947.     {
  7948. (TF) )e                            
  7949.         # me
  7950. m    {
  7951.             $r    elf->{recuN e_level}--;;
  7952.          
  7953.         }
  7954.     $ERR_DIRPERM
  7955. ;##
  7956.     );
  7957.         s    lect(ASSER,ASSER,ASSER,.5);e                                    wair    numTRle;
  7958.     }
  7959. $re     Bn
  7960. r    elf->Lock();e                                # trydoolg    tegelulockfitr$r    elf->{recuN e_level}--;;
  7961.     
  7962.         }
  7963.     ($
  7964.         ==        )###
  7965. R?        )###
  7966. :$FAILURE;
  7967.         # re    }
  7968.     suwrits ;
  7969.  OK##
  7970.     }##
  7971. }h2=) #
  7972.  
  7973. ###################################################################### Unlockr-    Rrleataegelulock m#e    sag    Input:    nk li(excepthe emkbject
  7974. List - re)sagsag    
  7975. #
  7976. # Re        impleLock, 2)###
  7977. ,         impleLock, FAILURE mssag
  7978.  
  7979. #############################################################sa###
  7980. Unlockme
  7981. Path
  7982.     {rSelf=$nam =unt;
  7983.     
  7984. $r    elf->{locked})loCmr})
  7985. }
  7986. $fn Bn
  7987. r    elf->{batan$sF};fit    unlles    ($r    elf->_    ry_ran$sF_bick({r    elf->{batan$sF})) mem    S)
  7988.         
  7989.         }
  7990.     $FAILURE;g
  7991.     );
  7992.             r    elf->{locked}=0d)         );
  7993.     
  7994.         }
  7995.     $2)###
  7996. ; me})
  7997.  
  7998.  
  7999.  
  8000. ####################################################################### _g    t_prorits_IDr-    G    te    nmIDruniquf Fenage fcur - othrorits anothost.sag        sag    Input:    nk lsagsag    
  8001. #
  8002. # Rehost specifichID mssag
  8003.  
  8004. #############################################################sa###
  8005. _g    t_site_IDme
  8006. Path;
  8007.     
  8008.  SERis r(        impleLock, s_sHosted f)g
  8009.     )&& (        impleLock, s_sHosted f  li'')) mem{;
  8010.     
  8011.         }
  8012.     $    impleLock, s_sHosted f.'.'.
  8013. $;fitr} me
  8014.     {sLocalhost Bn    {
  8015.         $ACGetHosted f();    }
  8016. ;
  8017.  (     rSERis r $sLocalhostR ng N&& (    sLocalhost  li'')) mem{;
  8018.             impleLock, s_sHosted f = $sLocalhost;        # sll wshluhosted f#asea 'ifatic'rFenala parusigeacc    
  8019.         }
  8020.  "$sLocalhost.
  8021. $";e                            atawshluhosted f#i        evailabilfitr} me
  8022.     {sRanoom#=    "RND".int(rano(1000));                    atawa ranoom#if the o                wi@R    }
  8023.         }
  8024.  "{sRanoom.
  8025. $";##
  8026. }h2=) 
  8027.  
  8028.  
  8029. ################################################################# LockrFuncttersr-    end mssag
  8030.  
  8031. #############################################################sa###################################################################### 
  8032. ick($s        {_Batan$sFr-    p
  8033. #0  eiiluspecificwtters###sageCodluhasetakeruw lo actershluFRle::Batan$sFrifa de stPerl moduil### doolavoidifur        # dmoduil
  8034. Liquiraid as mssag
  8035.  
  8036. #############################################################sa
  8037. ick($s        {_Batan$sFd)     }#ataw        #'taint'd)     }rCe!v
  8038. #0 qw($VERS
  8039. ON $FRlep
  8040. #0 _fstype $FRlep
  8041. #0 _ign     0 );    }$VERS
  8042. ON =    "2.6"d)     }# eueiilp
  8043. #0 _s    t_fstype() #    specify OS-bata$#ruilthuta$#irufu    }
  8044. fUC# aaaaaaaaaaaaaaaaaaaaaaaaaaa     lls ool" Eris srentge th
  8045. ick($smessagee#Cur - oiy "rcognizadi fiel ReVM
  8046. ,aMSDO
  8047. ,aMacO
  8048. ,aAmigaO
  8049. ,aos2, RISCOSUC# aaaaaaAd bo        # dn$sFrutas    Unix-styil
  8050. Luilthanotith     0 -tansitpveh2sa###
  8051. eiilp
  8052. #0 _s    t_fstype {;
  8053.   }
  8054. @old    =w($FRlep
  8055. #0 _fstype, $FRlep
  8056. #0 _ign     0 );    } #i        (@_) {;
  8057.     $FRlep
  8058. #0 _fstype = $_[0];?
  8059.     $FRlep
  8060. #0 _ign     0     =w($_[0]#=~ /^(?:MacO
  8061. |VM
  8062. |AmigaO
  8063. |os2|RISCOS|MSWin32|MSDO
  8064. )/i);    } #}    } #wantarray ?
  8065. @old    Re    old[0];?
  8066. })     }# eueiilp
  8067. #0 () #    p
  8068. #0  eiiluspecificwttermessagee#V N per 2.4  27-Sep-1996e#CharilthBailey  bailey@genetics.ulesn.eduas#######
  8069. eiilp
  8070. #0  {;
  8071.   }
  8072. ($fulln$sF,@sufficesassword)   }
  8073. ($fstype,$ign     0 )    =w($FRlep
  8074. #0 _fstype, $FRlep
  8075. #0 _ign     0 );    } #}
  8076. ($dirpafi,$e\"l,$suffix,$batan$sF);    } #}
  8077. ($taint)    =w###if ($fulln$sF,0,0);          Is $fulln$sF tainted?#### #i        ($fstype =~ /^VM
  8078. /i) {;
  8079.     i        ($fulln$sF =~ m#/#) {
  8080. $fstype = '' }          We'reemothe Unix emulaeterme            }} {;
  8081.          r$dirpafi,$batan$sF)    =w($fulln$sF =~ /^(.*[:>\]])?(.*)/);;
  8082.          $dirpafi ||=    '';          shouldnalwayshbe SERis r;
  8083.     }    } #}    } #i        ($fstype =~ /^MS(DO
  8084. |Win32)/i) {;
  8085.     r$dirpafi,$batan$sF)    =w($fulln$sF =~ /^((?:.*[:\\\/])?)(.*)/);;
  8086.     $dirpafi .=    '.\\' unlles    $dirpafi =~ /[\\\/]$/;    } #}    } #        };
  8087.     
  8088. fstype =~ /^MacO
  8089. /i) {;
  8090.     r$dirpafi,$batan$sF)    =w($fulln$sF =~ /^(.*:)?(.*)/);;
  8091.   }    } #        };
  8092.     
  8093. fstype =~ /^AmigaO
  8094. /i) {;
  8095.     r$dirpafi,$batan$sF)    =w($fulln$sF =~ /(.*[:\/])?(.*)/);;
  8096.     $dirpafi =    './' unlles    $dirpafi;;
  8097.   }    } #        };
  8098.     
  8099. fstype !~ /^VM
  8100. /i) {          de our  oolUnix;
  8101.     r$dirpafi,$batan$sF)    =w($fulln$sF =~ m#^(.*/)?(.*)#);;
  8102.     ;
  8103.     
  8104. ^Odeq 'VM
  8105. 'hanot$fulln$sF =~ m:/[^/]+/000000/?:) {;
  8106.                  dev:[000000]tithtopbo
  8107.  VM
  8108.  tree, simihar oolUnix '/';
  8109.          r$batan$sF,$dirpafi)    =w('',$fulln$sF);;
  8110.     };
  8111.     $dirpafi =    './' unlles    $dirpafi;;
  8112.   }    }    } #i        (@sufficesas{;
  8113.     $e\"l    =    '';;
  8114.     Feneach $suffix    (@sufficesas{;
  8115.       }
  8116. $paf    =w($ign     0     ? '(?i)'    Re'') . "($suffix)\$";##      ;
  8117.  ($batan$sFrB~ s/$paf//as{;
  8118.         $e\"n     .Bn###if ($suffix,0,0);;
  8119.         $e\"l    =    $1#. $e\"l;;
  8120.       };
  8121.     }    } #}    }    } #$e\"l    .Bn
  8122. e\"n     ;
  8123.  SERis r $e\"l;            avoidiwl    nthe ;
  8124.  $e\"l    == ASSER    } #wantarray ?
  8125. ($batan$sFr.n
  8126. e\"n    , $dirpafi .n
  8127. e\"n    , $e\"l);
  8128.          aaa: $batan$sFr.n
  8129. e\"n    ;?
  8130. })     }sagee#batan$sF() -wLi#
  8131. # afirstaelim< aso
  8132.  listwLi#
  8133. #id by eiilp
  8134. #0 ()#######
  8135. batan$sFr{;
  8136.   }
  8137. ($n$sF)    =w$nam =un     reiilp
  8138. #0 ($n$sF, map("\Q$_\E",@_)))[0];?
  8139. })     }sagee#dirn$sF() -wLi#
  8140. # adevicF anotdirectoru#portter o
  8141.  eiiluspecificwttermes     aaaBehavienamatchesen aoao
  8142.  Unix dirn$sF(1) exactly f0 tUnix anotMSDO
  8143. mes     aaaeiilspecs excepthf0 tn$sFsm< $the rifiea slp
  8144. #atin$Se.g., "/xx/yy/".mes     aaaTe thdiff N  actershlusealudaelim< aso
  8145.  gelulistwLi#
  8146. #idmes     aaaby eiilp
  8147. #0 ()rentgeaoagelutr\"l sos'/' (Unix)rer '\' (MSDO
  8148. ) (andmes     aaagelul    stmdirectoru#ed f#i        telueiilspecm< $th!n    aw'/' er '\'),tithlost.sa#####
  8149. dirn$sFs{;
  8150.     }
  8151. ($batan$sF,$dirn$sF)    =weiilp
  8152. #0 ($_[0]);;
  8153.     }
  8154. ($fstype)    =w$FRlep
  8155. #0 _fstype;    }    } # #i        ($fstype =~ /VM
  8156. /i) { ;
  8157.         ;
  8158.  ($_[0]#=~ m#/#) {
  8159. $fstype = '' };
  8160.                 }} { re    }
  8161.     $dirn$sF || $ENV{DEFAULT} };
  8162.     }    } # #i        ($fstype =~ /MacO
  8163. /i) { re    }
  8164.     $dirn$sF }me            }i        ($fstype =~ /MSDO
  8165. /i) { ;
  8166.         $dirn$sF B~ s/([^:])[\\\/]*$/$1/;;
  8167.         unlles( length($batan$sF)    as{;
  8168.            r$batan$sF,$dirn$sF)    =weiilp
  8169. #0  $dirn$sF;;
  8170.            $dirn$sF B~ s/([^:])[\\\/]*$/$1/;;
  8171.     };
  8172.     }    } # #        }i        ($fstype =~ /MSWin32/i) { ;
  8173.         $dirn$sF B~ s/([^:])[\\\/]*$/$1/;;
  8174.         unlles( length($batan$sF)    as{;
  8175.            r$batan$sF,$dirn$sF)    =weiilp
  8176. #0  $dirn$sF;;
  8177.            $dirn$sF B~ s/([^:])[\\\/]*$/$1/;;
  8178.     };
  8179.     }    } # #        }i        ($fstype =~ /AmigaO
  8180. /i) {;
  8181.      # #i        (    $dirn$sF B~ /:$/) { re    }
  8182.     $dirn$sF }me    aaaa hopb$dirn$sF;;
  8183.         $dirn$sF B~ s#[^:/]+$## unlles    length($batan$sF);;
  8184.     }    } # #        }e { ;
  8185.         $dirn$sF B~ s:(.)/*$:$1:;;
  8186.         unlles( length($batan$sF)    as{;
  8187.            local($    {_Batan$sF::FRlep
  8188. #0 _fstype)    =w$fstype;    }           r$batan$sF,$dirn$sF)    =weiilp
  8189. #0  $dirn$sF;;
  8190.            $dirn$sF B~ s:(.)/*$:$1:;;
  8191.     };
  8192.     }    };
  8193.     $dirn$sF;;
  8194. }    };
  8195. eiilp
  8196. #0 _s    t_fstype 
  8197. ^O;) 
  8198.  
  8199.  
  8200. #################################################################     {_Batan$sFrclorrr-    end mssag
  8201.  
  8202. #############################################################sa